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)
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()
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()
def testInsideTimeout(self): conn, addr = self.serv.accept() self.addCleanup(conn.close) time.sleep(3) conn.send("done!")
def _testRecv(self): self.cli.connect((HOST, self.port)) time.sleep(0.1) self.cli.send(MSG)
def _testAccept(self): time.sleep(0.1) self.cli.connect((HOST, self.port))
def _testClose(self): self.cli.connect((HOST, self.port)) time.sleep(1.0)
def testInsideTimeout (self): conn, addr = self.serv.accept() self.addCleanup(conn.close) time.sleep(3) conn.send("done!")
def _testRecv (self): self.cli.connect((HOST, self.port)) time.sleep(0.1) self.cli.send(MSG)
def _testAccept (self): time.sleep(0.1) self.cli.connect((HOST, self.port))
def _testClose (self): self.cli.connect((HOST, self.port)) time.sleep(1.0)