Пример #1
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])
Пример #2
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])
Пример #3
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))
Пример #4
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))
Пример #5
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)
            )
Пример #6
0
    def recvmsg(self, size):
        """
        For unreliable sending message receiving

        @return str(returned_data)
        """
        return udt4.recvmsg(self.__sock, size)  
Пример #7
0
    def recvmsg(self, size):
        """
        For unreliable sending message receiving

        @return str(returned_data)
        """
        return udt4.recvmsg(self.__sock, size)
Пример #8
0
    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)
Пример #9
0
    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)
Пример #10
0
    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
                        )
Пример #11
0
    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
                        )