예제 #1
0
파일: network.py 프로젝트: stendec/NakedSun
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.")
예제 #2
0
파일: echo.py 프로젝트: vasudevram/pants
from pants import Engine, Server, Stream


class Echo(Stream):
    def on_read(self, data):
        self.write(data)


Server(Echo).listen(4040)
Engine.instance().start()
예제 #3
0
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()