Is socket.recvfrom broken in ActiveState Python 3.2?

Discussion in 'Python' started by bbeacham@desanasystems.com, Aug 30, 2012.

  1. Guest

    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'?
    , Aug 30, 2012
    #1
    1. Advertising

  2. On Wed, 29 Aug 2012 17:38:28 -0700 (PDT),
    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
    HTTP://wlfraed.home.netcom.com/
    Dennis Lee Bieber, Aug 30, 2012
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wim Deprez

    migrating recvmsg() to recvfrom()

    Wim Deprez, Jul 21, 2004, in forum: C++
    Replies:
    1
    Views:
    698
    Wim Deprez
    Jul 25, 2004
  2. William

    recvfrom gives empty string

    William, Mar 23, 2005, in forum: C++
    Replies:
    2
    Views:
    1,631
    Malte Starostik
    Mar 23, 2005
  3. lgwe
    Replies:
    2
    Views:
    251
    Mark T
    Nov 4, 2007
  4. uncutstone
    Replies:
    5
    Views:
    135
    uncutstone
    May 16, 2006
  5. Replies:
    4
    Views:
    93
    Austin Ziegler
    Mar 5, 2007
Loading...

Share This Page