mirror of
https://github.com/dimoniche/changer.git
synced 2026-01-30 01:03:30 +03:00
26 lines
422 B
Python
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()
|