udpserver small test program

Import Socket, SYS, binascii 

IP = ' 127.0.0.1 ' 
Port = 9999 

S = socket.socket (socket.AF_INET, socket.SOCK_DGRAM) 
s.bind ((IP, Port)) 

Print (F ' binding port: {port ...} ' ) 

the while True: 
    Data, addr = s.recvfrom (1024 )
     Print ( ' received:% S:% S. ' % addr, ' sent the message: ' , binascii.b2a_hex (Data))
     Print ( ' - ' * 30, ' the OVER ','-' * 30)
    s.sendto(data,addr)

 

Guess you like

Origin www.cnblogs.com/ToCenTek/p/11333792.html