need a thread to keep a socket connection alive?

Serge Orlov Serge.Orlov at gmail.com
Mon Apr 24 11:19:26 EDT 2006


Roy Smith wrote:
> Serge Orlov <Serge.Orlov at gmail.com> wrote:
> > sockobj.settimeout(550)
> > [...]
> > Also, as other people pointed out, you'd better make buffered socket
> > with .makefile() socket method.
>
> If I understand the docs for the socket module correctly, these two
> suggestions are mutually incompatable.

Perhaps this restriction was lifted?

>>> s = socket.socket()
>>> s.settimeout(15)
>>> s.connect(("www.python.org", 80))
>>> f = s.makefile()
>>> f.readline()

Traceback (most recent call last):
  File "<pyshell#21>", line 1, in -toplevel-
    f.readline()
  File "C:\Python24\lib\socket.py", line 340, in readline
    data = self._sock.recv(self._rbufsize)
timeout: timed out
>>>




More information about the Python-list mailing list