def initialize(addr, http_addr): """ Initialize the servers and start listening. """ global main_server global http_server if not addr: addr = settings.get("main_addr", ":4000") if not http_addr: http_addr = settings.get("http_addr", ":8080") # Parse the addresses. addr = _parse_address(addr) http_addr = _parse_address(http_addr) # Create the main server. main_server = Server(SimpleTelnet) main_server.listen(addr) log.todo("Initialize the HTTP server.")
from pants import Engine, Server, Stream class Echo(Stream): def on_read(self, data): self.write(data) Server(Echo).listen(4040) Engine.instance().start()
from pants import Engine, Server, Stream class Echo(Stream): def on_read(self, data): self.write(data) server = Server(ConnectionClass=Echo) server.listen(4040) Engine.instance().start()