Moyka/test_app/udp_recvfrom.py
dimoniche f74fdcceac первый коммит
первый коммит
2019-05-27 23:42:26 +03:00

26 lines
422 B
Python

# Server program
from socket import *
# Set the socket parameters
host = "192.168.50.27"
port = 20002
buf = 1024
addr = (host,port)
# Create socket and bind to address
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)
# Receive messages
while 1:
data,addr = UDPSock.recvfrom(buf)
if not data:
print "Client has exited!"
break
else:
print "\nReceived message '", data,"'"
# Close socket
UDPSock.close()