def test0(): print('client: test0') if mode == 'DGRAM': dat = udt4.recvmsg(client, 4) msg = udt4.recvmsg(client, struct.unpack('I', dat)[0]) else: dat = udt4.recv(client, 4) msg = udt4.recv(client, struct.unpack('I', dat)[0])
def test0(): print("client: test0") if mode == "DGRAM": dat = udt4.recvmsg(client, 4) msg = udt4.recvmsg(client, struct.unpack("I", dat)[0]) else: dat = udt4.recv(client, 4) msg = udt4.recv(client, struct.unpack("I", dat)[0])
def test1(): print('client: test1') if mode == 'DGRAM': dat = udt4.recvmsg(client, 4) msg = udt4.recvmsg(client, struct.unpack('I', dat)[0]) else: dat = udt4.recv(client, 4) msg = udt4.recv(client, struct.unpack('I', dat)[0]) print('test1: %i %s' % (len(msg), msg))
def test1(): print("client: test1") if mode == "DGRAM": dat = udt4.recvmsg(client, 4) msg = udt4.recvmsg(client, struct.unpack("I", dat)[0]) else: dat = udt4.recv(client, 4) msg = udt4.recv(client, struct.unpack("I", dat)[0]) print("test1: %i %s" % (len(msg), msg))
def test1(): print('client: test1') if mode == 'DGRAM': dat = udt4.recvmsg(client, 4) msg = udt4.recvmsg(client, struct.unpack('I', dat)[0]) else: dat = udt4.recv(client, 4) msg = udt4.recv(client, struct.unpack('I', dat)[0]) print( 'test1: %i %s' % (len(msg), msg) )
def recvmsg(self, size): """ For unreliable sending message receiving @return str(returned_data) """ return udt4.recvmsg(self.__sock, size)
def runTest(self): Thread(target=self.runServer).start() udt.connect(self.recevr, '127.0.0.1', 8002) for k, i in enumerate([('a', 1), ('b', 2), ('c', 3)]): buf = i[0] * (10**i[1]) if k % 2 != 0: self.assertEquals(udt.sendmsg(self.recevr, buf, len(buf)), len(buf)) else: self.assertEquals(udt.recvmsg(self.recevr, len(buf)), buf)
def runServer(self): udt.bind(self.sender, '127.0.0.1', 8002) udt.listen(self.sender, 10) client, host = udt.accept(self.sender) for k, i in enumerate([('a', 1), ('b', 2), ('c', 3)]): buf = i[0] * (10**i[1]) if k % 2 == 0: self.assertEquals(udt.sendmsg(client, buf, len(buf)), len(buf)) else: self.assertEquals(udt.recvmsg(client, len(buf)), buf)
def runTest(self): Thread(target = self.runServer).start() udt.connect(self.recevr, '127.0.0.1', 8002) for k, i in enumerate([('a', 1), ('b', 2), ('c', 3)]): buf = i[0] * (10 ** i[1]) if k % 2 != 0: self.assertEquals( udt.sendmsg(self.recevr, buf, len(buf)), len(buf) ) else: self.assertEquals( udt.recvmsg(self.recevr, len(buf)), buf )
def runServer(self): udt.bind (self.sender, '127.0.0.1', 8002) udt.listen(self.sender, 10) client, host = udt.accept(self.sender) for k, i in enumerate([('a', 1), ('b', 2), ('c', 3)]): buf = i[0] * (10 ** i[1]) if k % 2 == 0: self.assertEquals( udt.sendmsg(client, buf, len(buf)), len(buf) ) else: self.assertEquals( udt.recvmsg(client, len(buf)), buf )