def connect(self):
     print "  connection #%s to node %s:%s" % (
         self.connId, self.node, self.port)
     if self.sd == None:
         self.sd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         self.sd.connect((self.node, self.port))
     self.scheduler.addFdHandler(Scheduler.FunctionalFdHandler(
             self.sd, waitInputFunc = lambda: True,
             handleInputFunc = self.eventInput))
Beispiel #2
0
    def createSocket(self):
        self.listenSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.listenSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.listenSocket.bind(("", self.config.port))
        self.listenSocket.listen(10000)

        self.scheduler.addFdHandler(
            Scheduler.FunctionalFdHandler(
                self.listenSocket,
                waitInputFunc=lambda: True,
                handleInputFunc=self.eventClientConnection))
Beispiel #3
0
    def connect(self):
        print "  connection #%s to node %s:%s (%s)" % (self.connId, self.node,
                                                       self.port, self.name)
        if self.sd == None:
            self.sd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.sd.connect((self.node, self.port))
            if self.args.proxy:
                assert self.proxyServer == None
                config = makeStruct(port=self.port +
                                    self.args.proxy_port_offset)
                self.proxyServer = GenericTcpServer(config, self.scheduler,
                                                    self.createClient)

        self.fdHandler = Scheduler.FunctionalFdHandler(
            self.sd,
            waitInputFunc=lambda: True,
            handleInputFunc=self.eventInput)
        self.scheduler.addFdHandler(self.fdHandler)