Title: socket module setblocking and settimeout problem
Type: behavior Stage:
Components: Versions: Python 2.7
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 :
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?

    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:

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?

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 instead.
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