Networking Forums

Networking Forums > Computer Networking > Linux Networking > python recvfrom not working when on different ip

Reply
Thread Tools Display Modes

python recvfrom not working when on different ip

 
 
Junior Member
Join Date: Jun 2011
Location: Englewood, CO
Posts: 2

 
      06-15-2011, 06:33 PM
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.
 
Reply With Quote
 
 
 
 
Junior Member
Join Date: Jun 2011
Location: Englewood, CO
Posts: 2

 
      06-16-2011, 05:52 PM
Another update here. I tried the same client server code on another network and it worked just like the way it should. But it just doesnt work in one network. I just can't guess what could be the problem. Is it some configuration in the network??
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
port forwarding: python scrypt or C ? Sambo Linux Networking 0 01-23-2008 10:09 PM
Multicast recvfrom not working?????? cs3266@gmail.com Linux Networking 3 06-26-2006 04:17 PM
recvfrom() unblocking.. how to do it? manu Linux Networking 4 04-21-2006 08:12 PM
problem with recvfrom Omega Linux Networking 0 11-21-2005 08:17 PM
SP1 Breaks Perl and Python =?Utf-8?B?Sm9kaU0=?= Windows Networking 2 04-13-2005 09:47 PM



1 2 3 4 5 6 7 8 9 10 11