28 lines
429 B
Python
28 lines
429 B
Python
|
# Client program
|
||
|
|
||
|
from socket import *
|
||
|
|
||
|
# Set the socket parameters
|
||
|
host = "localhost"
|
||
|
port = 49152
|
||
|
buf = 1024
|
||
|
addr = (host,port)
|
||
|
|
||
|
# Create socket
|
||
|
UDPSock = socket(AF_INET,SOCK_DGRAM)
|
||
|
|
||
|
def_msg = "===Enter message to send to server===";
|
||
|
print "\n",def_msg
|
||
|
|
||
|
# Send messages
|
||
|
while (1):
|
||
|
data = raw_input(">> ")
|
||
|
if not data:
|
||
|
break
|
||
|
else:
|
||
|
UDPSock.sendto(data,addr)
|
||
|
print "Sending message", data
|
||
|
|
||
|
# Close socket
|
||
|
UDPSock.close()
|