Esempio n. 1
0
 def __init__(self):
     self.lso = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.lso.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.lso.bind(("", echo_port))
     self.lso.listen(5)
     iodispatcher.when_read(self.lso, self.on_connect)
     self.csos = dict()  # cso -> event
Esempio n. 2
0
 def on_connect(self, event):
     D("on_connect()")
     cso, paddr = self.lso.accept()
     self.csos[cso] = iodispatcher.when_read(cso, self.on_read)
     return 1