Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Is socket.recvfrom broken in ActiveState Python 3.2?

Reply
Thread Tools

Is socket.recvfrom broken in ActiveState Python 3.2?

 
 
bbeacham@desanasystems.com
Guest
Posts: n/a
 
      08-30-2012
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'?

 
Reply With Quote
 
 
 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      08-30-2012
On Wed, 29 Aug 2012 17:38:28 -0700 (PDT), http://www.velocityreviews.com/forums/(E-Mail Removed)
declaimed the following in gmane.comp.python.general:


>
> 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...

>>> d, sa = ("string",)

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ValueError: need more than 1 value to unpack

> In the code is this line:
> print('RECEIVED:', data, "SENDER:", str(senderAddr))
>
> and this is the output.
> RECEIVED: Hello, world SENDER: None
>


>>> d, sa = ("string", None)
>>> str(sa)

'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.
--
Wulfraed Dennis Lee Bieber AF6VN
(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
ActiveState Python Together with "Regular" Python) ((DLE) W. eWatson Python 5 01-13-2009 02:16 AM
Why are "broken iterators" broken? Steven D'Aprano Python 8 09-28-2008 09:19 PM
Re: Why are "broken iterators" broken? Fredrik Lundh Python 0 09-22-2008 04:32 PM
Re: Why are "broken iterators" broken? Cameron Simpson Python 0 09-22-2008 04:32 AM
Python 2.2 (ActiveState, build 224) and access violations/Dr Watson(long) =?iso-8859-1?q?Lars_Bj=F8nnes?= Python 1 10-16-2003 12:24 AM



Advertisments