Пример #1
0
def run_interaction (run_client):
    s, port = init_server()
    start_new_thread(handle_request, (s, run_client))
    if run_client:
        start_new_thread(make_request, (port,))
    sleep(0.1 + SOCKET_TIMEOUT)
    #print sys.getrefcount(s.fd)
    #s.close()
    return weakref.ref(s.fd)
Пример #2
0
 def clientSetUp(self):
     # The is a hittable race between serverExplicitReady() and the
     # accept() call; sleep a little while to avoid it, otherwise
     # we could get an exception
     time.sleep(0.1)
     self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM)
     addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE,
             TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0)
     self.cli.connect(addr)
     self.cliaddr = self.cli.getsockname()
Пример #3
0
 def clientSetUp (self):
     # The is a hittable race between serverExplicitReady() and the
     # accept() call; sleep a little while to avoid it, otherwise
     # we could get an exception
     time.sleep(0.1)
     self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM)
     addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE,
             TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0)
     self.cli.connect(addr)
     self.cliaddr = self.cli.getsockname()
Пример #4
0
 def testInsideTimeout(self):
     conn, addr = self.serv.accept()
     self.addCleanup(conn.close)
     time.sleep(3)
     conn.send("done!")
Пример #5
0
 def _testRecv(self):
     self.cli.connect((HOST, self.port))
     time.sleep(0.1)
     self.cli.send(MSG)
Пример #6
0
 def _testAccept(self):
     time.sleep(0.1)
     self.cli.connect((HOST, self.port))
Пример #7
0
 def _testClose(self):
     self.cli.connect((HOST, self.port))
     time.sleep(1.0)
Пример #8
0
 def testInsideTimeout (self):
     conn, addr = self.serv.accept()
     self.addCleanup(conn.close)
     time.sleep(3)
     conn.send("done!")
Пример #9
0
 def _testRecv (self):
     self.cli.connect((HOST, self.port))
     time.sleep(0.1)
     self.cli.send(MSG)
Пример #10
0
 def _testAccept (self):
     time.sleep(0.1)
     self.cli.connect((HOST, self.port))
Пример #11
0
 def _testClose (self):
     self.cli.connect((HOST, self.port))
     time.sleep(1.0)