Ok so i am a newbie into networking.
I wrote a python script to be a client and another python script to be a server. I used UDP sockets inside both and used sento and recvfrom to post and receive. No when i have both the client and server on the same system using localhost as the host, messages are transferred with ease. Now when I put the server script on a actual server, it does not receive. I put the host ids on both the scripts as the IP of the server. I tried tcpdump and found out that messages are actually sent to the destination port and netstat confirms that the port is listening. Now here is a little twist the server has 3 interfaces.. eth1 , eth0 and lo. I dont know how to specify what to aim at but i know tcpdump shows that eth0 is the one thats getting messages. I tried with the IP's of both interfaces and still doesn't work. I cant understand how can a port listen and get messages but still not show it.
here is the code:
//Server
import socket,struct,IN
# Set the socket parameters
host = "10.73.***.**"
port = 45333
buf = 1029
addr = (host,port)
# Create socket and bind to address
UDPSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
UDPSock.bind(addr)
# Receive messages
while 1:
data,addr = UDPSock.recvfrom(buf)
if not data:
print "Client has exited!"
else:
print "\nReceived message '", data,"'"
# Close socket
UDPSock.close()
************************************************** ***
//client
import socket
MCAST_GRP = '10.73.***.**'
MCAST_PORT = 45333
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
#sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
while 1:
sock.sendto("robot", (MCAST_GRP, MCAST_PORT))
************************************************** ********
SOMEBODY PLEASE HELP.
|