def _post_open(self, cond): AbstractClient._post_open(self) # The IO_OUT event would normally indicate that the socket has finished # connecting. To handle this we would use the following code: # if cond & IO_OUT: # return True # else: # return False # Due to a bug in glib the IO_OUT event is sent prematurely, therefore # we use the following code until the bug in glib is fixed: try: self._transport.recv(0) except Exception, e: #the following exceptions can be raised: # socket.error (error, message) # openSSL.SSL.SysCallError (error, message) # openSSL.SSL.WantReadError () try: (error, message) = e #the socket is connected if we don't get the ENOTCONN error if error != ENOTCONN: self._watch_remove() return True else: return False # the openSSL.SSL.WantReadError -> socket is connected except: self._watch_remove() return True
def __init__(self, client_id=None, name="", pin=None, debt=None, debt_limit=None): AbstractClient.__init__(self, client_id, name) if debt is not None: self._debt = debt self._pin = str(pin) if debt_limit is not None: self._debt_limit = debt_limit
def _pre_open(self, io_object): io_object.setblocking(False) channel = gobject.IOChannel(io_object.fileno()) channel.set_flags(channel.get_flags() | gobject.IO_FLAG_NONBLOCK) channel.set_encoding(None) channel.set_buffered(False) self._transport = io_object self._channel = channel self._source_id = None self._source_condition = 0 self._outgoing_queue = [] AbstractClient._pre_open(self)
def _pre_open(self, io_object): io_object.setblocking(False) channel = gobject.IOChannel(io_object.fileno()) channel.set_flags(channel.get_flags() | gobject.IO_FLAG_NONBLOCK) channel.set_encoding(None) channel.set_buffered(False) self._transport = io_object self._channel = channel self._source_id = None self._source_condition = 0 self._outgoing_queue = [] AbstractClient._pre_open(self)
def _post_open(self): AbstractClient._post_open(self) self._watch_remove()
def __init__(self, host, port, domain=AF_INET, type=SOCK_STREAM): AbstractClient.__init__(self, host, port, domain, type)
def _post_open(self): AbstractClient._post_open(self) self._watch_remove()
def __init__(self, host, port, domain=AF_INET, type=SOCK_STREAM): AbstractClient.__init__(self, host, port, domain, type)