classification
Title: socket module setblocking and settimeout problem
Type: behavior Stage:
Components: Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Frank.Ling, pitrou
Priority: normal Keywords:

Created on 2012-06-28 07:26 by Frank.Ling, last changed 2012-06-29 01:18 by pitrou. This issue is now closed.

Messages (4)
msg164225 - (view) Author: Frank Ling (Frank.Ling) Date: 2012-06-28 07:26
i use socket such as :
        self.socket.setblocking(1)
        self.socket.settimeout(1)
but this socket is no-block ,i find socketmodule.c sock_settimeout

    s->sock_timeout = timeout;
    internal_setblocking(s, timeout < 0.0);

if timeout >0, so internal_setblocking(s,false=0),so socket is no-block

by the way:
  in sock_settimeout,call internal_setblocking params have error?

init_sockobject:
    if (defaulttimeout >= 0.0)
        internal_setblocking(s, 0);
msg164236 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-28 10:26
Yes, this is normal. Timeout sockets use a non-blocking fd internally:
http://docs.python.org/dev/library/socket.html#notes-on-socket-timeouts

This won't be visible to you if you only use the socket object, but it will if you call fileno() and use the file descriptor directly.
msg164310 - (view) Author: Frank Ling (Frank.Ling) Date: 2012-06-29 01:14
how to create socket and have block timeout mode?

        self.socket.setblocking(1)
        self.socket.settimeout(1)
this program is error?
msg164311 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-06-29 01:18
Frank, this bug tracker is not for posting general programming questions.
Please see http://mail.python.org/mailman/listinfo/python-list instead.
History
Date User Action Args
2012-06-29 01:18:36pitrousetmessages: + msg164311
2012-06-29 01:14:47Frank.Lingsetmessages: + msg164310
2012-06-28 10:26:26pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg164236

resolution: wont fix
2012-06-28 07:26:19Frank.Lingcreate