<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def unbuffered_write(self, buf):
 """Performs an unbuffered write, the default unless socket.send does not send everything, in which case an unbuffered write is done and the write method is set to be a buffered write until the buffer is empty once again. buf -- bytes to send """

        if self.closed:
            raise ConnectionClosed()

        result = 0
        try:
            result = self.sock.send(buf)
        except EnvironmentError as e:
            # if the socket is simply backed up ignore the error 
            if e.errno != errno.EAGAIN: 
                self._close(e)
                return

        # when the socket buffers are full/backed up then we need to poll to see
        # when we can write again
        if result != len(buf):
            self.write = self.buffered_write
            self.write_watcher.start()
            self.write(buf[result:])