def receive(options): global _MyIDURL global _MyHost global _InternalPort global _Listener from transport.tcp import tcp_interface if _Listener: tcp_interface.interface_receiving_failed('already listening') return None try: _MyIDURL = options['idurl'] _InternalPort = int(options['tcp_port']) _Listener = reactor.listenTCP(_InternalPort, TCPFactory(None, keep_alive=True)) _MyHost = options['host'].split(':')[0] + ':' + str(_InternalPort) tcp_interface.interface_receiving_started(_MyHost, options) except CannotListenError as ex: tcp_interface.interface_receiving_failed('port is busy') except Exception as ex: # print err, dir(err) try: e = ex.getErrorMessage() except: e = str(ex) tcp_interface.interface_receiving_failed(e) # lg.exc() return _Listener
def receive(options): global _MyIDURL global _MyHost global _InternalPort global _Listener from transport.tcp import tcp_interface if _Debug: lg.out(_DebugLevel, 'tcp_node.receive %r' % options) if _Listener: lg.warn('listener already exist') tcp_interface.interface_receiving_started(_MyHost, options) return _Listener try: _MyIDURL = options['idurl'] _InternalPort = int(options['tcp_port']) except: _MyIDURL = None _InternalPort = None lg.exc() return None try: _Listener = reactor.listenTCP( _InternalPort, TCPFactory(None, keep_alive=True)) # @UndefinedVariable _MyHost = net_misc.pack_address( (options['host'].split(b':')[0], int(_InternalPort))) tcp_interface.interface_receiving_started(_MyHost, options) except CannotListenError as ex: lg.warn('port "%d" is busy' % _InternalPort) tcp_interface.interface_receiving_failed('port is busy') return None except Exception as ex: try: e = ex.getErrorMessage() except: e = str(ex) tcp_interface.interface_receiving_failed(e) lg.exc() return None return _Listener
def receive(options): global _MyIDURL global _MyHost global _InternalPort global _Listener from transport.tcp import tcp_interface if _Listener: lg.warn('listener already exist') tcp_interface.interface_receiving_started(_MyHost, options) return _Listener try: _MyIDURL = options['idurl'] _InternalPort = int(options['tcp_port']) except: _MyIDURL = None _InternalPort = None lg.exc() return None try: _Listener = reactor.listenTCP(_InternalPort, TCPFactory(None, keep_alive=True)) _MyHost = options['host'].split(':')[0] + ':' + str(_InternalPort) tcp_interface.interface_receiving_started(_MyHost, options) except CannotListenError as ex: lg.warn('port "%d" is busy' % _InternalPort) tcp_interface.interface_receiving_failed('port is busy') return None except Exception as ex: try: e = ex.getErrorMessage() except: e = str(ex) tcp_interface.interface_receiving_failed(e) lg.exc() return None return _Listener