Socket recv(1) seems to block instead of returning end of file.

Grant Edwards grante at visi.com
Fri Aug 24 10:37:28 EDT 2007


On 2007-08-24, Bryan Olson <fakeaddress at nowhere.org> wrote:
> Grant Edwards wrote:
> [...]
>> import socket,random
>> 
>> HOST = ''                 # Symbolic name meaning the local host
>> PORT = 8765               # Arbitrary non-privileged port
>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>> s.connect((HOST, PORT))
>
> Actually the empty string passed for the host means INADDR_ANY,

You're correct.  I copied that code from the server example on
the Python socket module doc page, and forgot to change the host.

  http://docs.python.org/lib/socket-example.html

> which does not really make sense for the client. On my Win-XP
> system, the client fails with
>
>    socket.error: (10049, "Can't assign requested address")

It's interesting that it works on Linux.

> For the loop-back adapter, 'localhost' or '127.0.0.1' should
> work.

Yup.

-- 
Grant Edwards                   grante             Yow! YOU PICKED KARL
                                  at               MALDEN'S NOSE!!
                               visi.com            



More information about the Python-list mailing list