Ejemplo n.º 1
0
 def connect(self, address, port):
     '''
     Function for connecting to server.
     '''
     try:
         if not self.socket:
             self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
         asynchat.async_chat.connect(self, (address, port))
     except socket.error, err:
         if not connection.minorSocketError(err):
             self.messages.put(Error(err))
Ejemplo n.º 2
0
 def connect(self, address, port):
     '''
     Function for connecting to server.
     '''
     try:
         if not self.socket:
             self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
         asynchat.async_chat.connect(self, (address, port))
     except socket.error, err:
         if not connection.minorSocketError(err):
             self.messages.put(Error(err))
Ejemplo n.º 3
0
 def handle_error(self):
     '''
     Method for handling uncaptured errors.
     '''
     t, err, tbinfo = asyncore.compact_traceback()[1:]
     self.onError(Exception("%s:%s\n%s"
                             % (t, err, tbinfo[1:-1].replace("] [", "\n"))))
     if isinstance(err, socket.error):
         if connection.closingSocketError(err):
             pass
         elif connection.minorSocketError(err):
             return
         else:
             self.onError(connection.ConnectionError(
                                         connection.processSocketError(err)))
     self.disconnect()
Ejemplo n.º 4
0
 def handle_error(self):
     '''
     Method for handling uncaptured errors.
     '''
     err = asyncore.compact_traceback()[2]
     error = Error(err)
     if isinstance(err, socket.error):
         if connection.closingSocketError(err):
             self.handle_close()
             return
         elif connection.minorSocketError(err):
             self.disconnect()
             return
         elif err[0] in (10060, 110):
             #WSATIMEDOUT error keeps occurring if socket isn't closed
             self.disconnect()
         elif err[0] in self.errorStrs:
             error = ConnectionRefusedError(self.errorStrs[err[0]])
             self.disconnect()
         else:
             error = ConnectionRefusedError(
                 connection.processSocketError(err))
             self.disconnect()
     self.messages.put(error)
Ejemplo n.º 5
0
 def handle_error(self):
     '''
     Method for handling uncaptured errors.
     '''
     err = asyncore.compact_traceback()[2]
     error = Error(err)
     if isinstance(err, socket.error):
         if connection.closingSocketError(err):
             self.handle_close()
             return
         elif connection.minorSocketError(err):
             self.disconnect()
             return
         elif err[0] in (10060, 110):
             #WSATIMEDOUT error keeps occurring if socket isn't closed
             self.disconnect()
         elif err[0] in self.errorStrs:
             error = ConnectionRefusedError(self.errorStrs[err[0]])
             self.disconnect()
         else:
             error = ConnectionRefusedError(
                                 connection.processSocketError(err))
             self.disconnect()
     self.messages.put(error)