Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28082 > unrolled thread
| Started by | bbeacham@desanasystems.com |
|---|---|
| First post | 2012-08-29 17:38 -0700 |
| Last post | 2012-08-29 22:22 -0400 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Is socket.recvfrom broken in ActiveState Python 3.2? bbeacham@desanasystems.com - 2012-08-29 17:38 -0700
Re: Is socket.recvfrom broken in ActiveState Python 3.2? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-29 22:22 -0400
| From | bbeacham@desanasystems.com |
|---|---|
| Date | 2012-08-29 17:38 -0700 |
| Subject | Is socket.recvfrom broken in ActiveState Python 3.2? |
| Message-ID | <cf594a09-d5d2-4d92-912e-b283f4a2fa07@googlegroups.com> |
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'?
[toc] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2012-08-29 22:22 -0400 |
| Message-ID | <mailman.3953.1346293361.4697.python-list@python.org> |
| In reply to | #28082 |
On Wed, 29 Aug 2012 17:38:28 -0700 (PDT), bbeacham@desanasystems.com
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
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web