def get_tcp_server(port, addr="", workerclass=TestWorker): s = socket.tcp_listener((addr, port), 5, TCPSocketServer) s.set_worker(workerclass) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) asyncio.stop_sigio() asyncio.poller.register(s) return s
def simple_http_server(argv): port = argv[1] if len(argv) > 1 else 8080 sock = socket.tcp_listener(("", int(port)), 500) srv = asyncserver.AsyncServerHandler(sock, asyncserver.AsyncWorkerHandler, http_protocols.BasicHTTPServerProto()) try: asyncserver.poller.loop() finally: asyncserver.poller.unregister_all()
def simple_http_server(argv): port = argv[1] if len(argv) > 1 else 8080 sock = socket.tcp_listener(("", int(port)), 500) srv = asyncserver.AsyncServerHandler( sock, asyncserver.AsyncWorkerHandler, http_protocols.BasicHTTPServerProto()) try: asyncserver.poller.loop() finally: asyncserver.poller.unregister_all()
def __init__(self, workerclass, protocol, port=None, host="", processmodel=None, debug=False): if port is None: port = workerclass.port self._procmanager = processmodel or ForkingModel() self.workerclass = workerclass self.engine = protocol self.debug = debug self._sock = socket.tcp_listener((host, port), 5) if debug: global debugger from pycopia import debugger
def __init__(self, workerclass, protocol, port=None, host=None, processmodel=None, debug=False): port = port or workerclass.PORT or self.PORT host = host or "" self._procmanager = processmodel or ForkingModel() self.workerclass = workerclass self.protocol = protocol self.debug = debug self._sock = socket.tcp_listener((host, port), 5) _host, self.server_port = self._sock.getsockname() self.server_name = socket.getfqdn(_host) if debug: global debugger from pycopia import debugger
def __init__(self, port, host=""): self._sock = socket.tcp_listener((host, port), 1)