Hi,
I have the Client Server Socket program on python. In both the Client and Server I use the loopback address. But kindly assist how to use this code and apply on different Client Server machines Eg (Server IP 192.168.1.4 & Client IP 192.168.1.5)
# Server program
from socket import *
host = "localhost"
port = 21567
buf = 1024
addr = (host,port)
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)
while 1:
data,addr = UDPSock.recvfrom(buf)
if not data:
print "Client has exited!"
break
else:
print "\nReceived message '", data,"'"
UDPSock.close()
# Client program
from socket import *
host = "localhost"
port = 21567
buf = 1024
addr = (host,port)
UDPSock = socket(AF_INET,SOCK_DGRAM)
def_msg = "===Enter message to send to server===";
print "\n",def_msg
while (1):
data = raw_input('>> ')
if not data:
break
else:
if(UDPSock.sendto(data,addr)):
print "Sending message '",data,"'....."
UDPSock.close()