def accept_client(): print('waiting on client') sock, host = udt4.accept(server) print('client found: %s %s' % host) return sock
def accept_client(): print("waiting on client") sock, host = udt4.accept(server) print("client found: %s" % host) return sock
def accept_client(): print('waiting on client') sock, host = udt4.accept(server) print( 'client found: %s %s' % host ) return sock
def accept(self): """ Blocking call. Currently this call will block permanently and EscapeExceptions will not break its execution (unforunately) @return tuple( UdtSocket(sock), str(host) ) """ accept = udt4.accept(self.__sock) return UdtSocket(_sock = accept[0]), accept[1]
def accept(self): """ Blocking call. Currently this call will block permanently and EscapeExceptions will not break its execution (unforunately) @return tuple( UdtSocket(sock), str(host) ) """ accept = udt4.accept(self.__sock) return UdtSocket(_sock=accept[0]), accept[1]
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 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 )
#!/usr/bin/env python import socket as socklib import struct import udt4 socket = udt4.socket(socklib.AF_INET, socklib.SOCK_STREAM, 0) udt4.bind(socket, '127.0.0.1', 3001) udt4.listen(socket, 10) sock, host = udt4.accept(socket) # send message # message = 'message in a bottle' udt4.send(sock, struct.pack('I', len(message)), 4) udt4.send(sock, message, len(message)) # recv message # msg_len = struct.unpack('I', udt4.recv(sock, 4))[0] message = udt4.recv(sock, msg_len) print( 'received message: %s' % message ) assert len(message) == msg_len, 'invalid message'