Is socket.recvfrom broken in ActiveState Python 3.2?

B

bbeacham

Obviously, this my issue, but I cannot figure out what I am doing wrong.

I have the Python echo server example implemented with the server on a Windows 7 computer and the client on a Linux Redhat server.

The line 'data = sock.recv(1024)' works as expected on the Linux client.

However, the line 'data, senderAddr = sock.recvfrom(1024)' does not set the 'senderAddr' to anything.

In the code is this line:
print('RECEIVED:', data, "SENDER:", str(senderAddr))

and this is the output.
RECEIVED: Hello, world SENDER: None

On the Windows 7 server side the line 'data = conn.recv(1024)' works fine.

However, the line 'data, remoteAddr = conn.recvfrom(1024)' gives this output;
DATA: Hello, world FROM: (0, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

While I expect this to be my issue, I cannot find an example via Google as to what I am doing wrong. All examples are pretty much as above.

Any ideas. Is this a bug in 'recvfrom'?
 
D

Dennis Lee Bieber

However, the line 'data, senderAddr = sock.recvfrom(1024)' does not set the 'senderAddr' to anything.
No -- if .recvfrom() didn't return a senderAddr you'd get an error
on the tuple unpack...
Traceback (most recent call last):
In the code is this line:
print('RECEIVED:', data, "SENDER:", str(senderAddr))

and this is the output.
RECEIVED: Hello, world SENDER: None

So senderAddr was either set to None; or is some object whose
__str__() method returns None... What does repr(senderAddr) give you?
Any ideas. Is this a bug in 'recvfrom'?

Since it is documented that the behavior depends upon the underlying
OS socket implementation, you may need to look at those.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top