Called by the pyev watcher (self.write_watcher) whenever the socket
        is writtable.

        Calls send using the userspace buffer (self.write_buffer) and checks
        for errors. If there are no errors then continue on as before.
        Otherwise closes the socket and calls close_cb with the error.

def _writtable(self, watcher, events):
        """Called by the pyev watcher (self.write_watcher) whenever the socket
        is writtable.

        Calls send using the userspace buffer (self.write_buffer) and checks
        for errors. If there are no errors then continue on as before.
        Otherwise closes the socket and calls close_cb with the error.

        """
        try:
            sent = self.sock.send(bytes(self.write_buffer))
            self.write_buffer = self.write_buffer[sent:]
            if len(self.write_buffer) == 0:
                self.write_watcher.stop()
                self.write = self.unbuffered_write
        except EnvironmentError as e:
            self._close(e)