socket settimeout ?

Colin Brown cbrown at metservice.com
Tue Dec 2 19:28:04 EST 2003


I have set up a socket listener that needs to listen indefinitely. On an
incoming call I get a connection object that I want to set a timeout on
[Win2k, Py2.3.2]. As the setdefaulttimeout method did not work with the new
connection I found (using dir on the socket._socket object) a settimeout
method. Is this (undocumented) method peculiar to Windows or fully
cross-platform?

code fragment:
        conn = rcv.nextConnAddr()
        print conn
        print
        print dir(conn[0])
        conn[0].settimeout(30.0)
        rcv.rxThread(conn)
output:
(<socket._socketobject object at 0x0095B7E0>, ('10.10.192.240', 3524))

['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__',
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__slots__', '__str__', '_sock', 'accept',
'bind', 'close', 'connect', 'connect_ex', 'dup', 'fileno', 'getpeername',
'getsockname', 'getsockopt', 'gettimeout', 'listen', 'makefile', 'recv',
'recvfrom', 'send', 'sendall', 'sendto', 'setblocking', 'setsockopt',
'settimeout', 'shutdown']

Thanks
Colin Brown
PyNZ








More information about the Python-list mailing list