def __init__(self, host='', port=502, **kwargs): if _debug: ModbusServer._debug("__init__ host=%r port=%r %r", host, port, kwargs) Client.__init__(self) Server.__init__(self) # create and bind self.serverDirector = TCPServerDirector((host, port), **kwargs) bind(self, StreamToPacket(stream_to_packet), self.serverDirector)
def main(): # check the version if (sys.version_info[:2] != (2, 5)): sys.stderr.write("Python 2.5 only\n") sys.exit(1) # parse the command line arguments parser = ArgumentParser(description=__doc__) parser.add_argument( "host", nargs='?', help="listening address of server or 'any' (default %r)" % (SERVER_HOST, ), default=SERVER_HOST, ) parser.add_argument( "port", nargs='?', type=int, help="server port (default %r)" % (SERVER_PORT, ), default=SERVER_PORT, ) args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # extract the server address and port host = args.host if host == "any": host = '' server_address = (host, args.port) if _debug: _log.debug(" - server_address: %r", server_address) # create a director listening to the address this_director = TCPServerDirector(server_address) if _debug: _log.debug(" - this_director: %r", this_director) # create an echo echo_master = EchoMaster() if _debug: _log.debug(" - echo_master: %r", echo_master) # bind everything together bind(echo_master, this_director) bind(MiddleManASE(), this_director) _log.debug("running") run() _log.debug("fini")
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) parser.add_argument( "--host", nargs='?', help="listening address of server", default=default_server_host, ) parser.add_argument( "--port", nargs='?', type=int, help="server port", default=default_server_port, ) args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # extract the server address and port host = args.host if host == "any": host = '' port = args.port server_address = (host, port) if _debug: _log.debug(" - server_address: %r", server_address) # create a director listening to the address this_director = TCPServerDirector(server_address) if _debug: _log.debug(" - this_director: %r", this_director) # create an echo echo_master = EchoMaster() if _debug: _log.debug(" - echo_master: %r", echo_master) # bind everything together bind(echo_master, this_director) bind(MiddleManASE(), this_director) _log.debug("running") run()
def main(): global args, this_application # parse the command line arguments parser = ConfigArgumentParser(description=__doc__) parser.add_argument( "host", nargs='?', help="listening address of server or 'any' (default %r)" % (SERVER_HOST,), default=SERVER_HOST, ) parser.add_argument( "port", nargs='?', type=int, help="server port (default %r)" % (SERVER_PORT,), default=SERVER_PORT, ) parser.add_argument( "--idle-timeout", nargs='?', type=int, help="idle connection timeout", default=IDLE_TIMEOUT, ) parser.add_argument( "--hello", action="store_true", default=False, help="send a hello message to a client when it connects", ) args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a device object this_device = LocalDeviceObject(ini=args.ini) if _debug: _log.debug(" - this_device: %r", this_device) # make a simple application this_application = BIPSimpleApplication(this_device, args.ini.address) # extract the server address and port host = args.host if host == "any": host = '' server_address = (host, args.port) if _debug: _log.debug(" - server_address: %r", server_address) # create a director listening to the address this_director = TCPServerDirector(server_address, idle_timeout=args.idle_timeout) if _debug: _log.debug(" - this_director: %r", this_director) # create a client write_property_client = WritePropertyClient() if _debug: _log.debug(" - write_property_client: %r", write_property_client) # bind everything together bind(write_property_client, this_director) bind(WritePropertyASE(), this_director) _log.debug("running") run() _log.debug("fini")
if 'addPeer' in kwargs: if _debug: ConnectionASE._info(" - add peer %s", kwargs['addPeer']) if 'delPeer' in kwargs: if _debug: ConnectionASE._info(" - delete peer %s", kwargs['delPeer']) # # __main__ # try: # parse the command line arguments args = ArgumentParser(description=__doc__).parse_args() _log.debug("initialization") director = TCPServerDirector(server_addr, actorClass=TCPPickleServerActor) echo_master = EchoMaster() bind(echo_master, director) bind(ConnectionASE(), director) _log.debug("running") run() except Exception, e: _log.exception("an error has occurred: %s", e) finally: _log.debug("finally")
def main(): global args # parse the command line arguments parser = ArgumentParser(description=__doc__) parser.add_argument( "host", nargs='?', help="listening address of server or 'any' (default %r)" % (SERVER_HOST, ), default=SERVER_HOST, ) parser.add_argument( "port", nargs='?', type=int, help="server port (default %r)" % (SERVER_PORT, ), default=SERVER_PORT, ) parser.add_argument( "--idle-timeout", nargs='?', type=int, help="idle connection timeout", default=IDLE_TIMEOUT, ) parser.add_argument( "--hello", action="store_true", default=False, help="send a hello message to a client when it connects", ) args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # extract the server address and port host = args.host if host == "any": host = '' server_address = (host, args.port) if _debug: _log.debug(" - server_address: %r", server_address) # create a director listening to the address this_director = TCPServerDirector(server_address, idle_timeout=args.idle_timeout) if _debug: _log.debug(" - this_director: %r", this_director) # create an echo echo_master = EchoMaster() if _debug: _log.debug(" - echo_master: %r", echo_master) # bind everything together bind(echo_master, this_director) bind(MiddleManASE(), this_director) _log.debug("running") run() _log.debug("fini")
ConnectionASE._debug(' - director.servers: %r', director.servers) # # __main__ # try: # parse the command line arguments args = ArgumentParser(description=__doc__).parse_args() _log.debug("initialization") # create a director listening to the address director = TCPServerDirector(server_addr) # create an echo echo_master = EchoMaster() # bind everything together bind(echo_master, director) bind(ConnectionASE(), director) _log.debug("running") run() except Exception, e: _log.exception("an error has occurred: %s", e) finally: