From: David Schwartz on 11 Mar 2010 20:27 On Mar 10, 3:37 pm, Ian Collins <ian-n...(a)hotmail.com> wrote: > Why? If the socket is writeable, it is connected. Right, but you have no idea if the socket is writable or not. A 'select' hit for writability only means that it is no longer possible to wait for it to *become* writable and that you need to either perform an operation or remove the socket from your select set. As soon as the connection fails, it is no longer possible to wait for the socket to become writable. Since your 'select' is attempting something that is no longer possible, it returns. This condition is reported to you by reporting the socket writable. For 'select', "writable" really means "stop waiting for writability". DS
From: Ian Collins on 11 Mar 2010 21:14 On 03/12/10 02:27 PM, David Schwartz wrote: > On Mar 10, 3:37 pm, Ian Collins<ian-n...(a)hotmail.com> wrote: > >> Why? If the socket is writeable, it is connected. > > Right, but you have no idea if the socket is writable or not. A > 'select' hit for writability only means that it is no longer possible > to wait for it to *become* writable and that you need to either > perform an operation or remove the socket from your select set. > > As soon as the connection fails, it is no longer possible to wait for > the socket to become writable. Since your 'select' is attempting > something that is no longer possible, it returns. This condition is > reported to you by reporting the socket writable. Won't the corresponding errorfd be set? -- Ian Collins
From: David Schwartz on 12 Mar 2010 12:48 On Mar 11, 6:14 pm, Ian Collins <ian-n...(a)hotmail.com> wrote: > Won't the corresponding errorfd be set? No. There is no such thing as an 'errorfd' in 'select'. That's a common misunderstanding. The 'poll' operation has that concept, but 'select' does not. DS
From: David Schwartz on 12 Mar 2010 12:50 On Mar 10, 1:41 pm, cerr <ron.egg...(a)gmail.com> wrote: > I have an application that tries to establish a TCP connection to a > server usingf connect. If the server does not exist it seems as if it > tries foirever before it eventually times out. How can i reduce this > timeout? You don't have to wait any longer than you want to. Write your code to wait as long as you want. > I'm interested in knowing fast er that the connection can not be > established. That is impossible. You are already being told that the connection cannot be established as soon as that is known. If you want to stop trying or try something else too before that, you can. But the implementation cannot tell you the connection has definitively failed until it definitively fails. DS
From: Nicolas George on 12 Mar 2010 13:01
David Schwartz wrote in message <aa489afe-7b96-41c3-8fda-44f45471ad65(a)s36g2000prh.googlegroups.com>: > No. There is no such thing as an 'errorfd' in 'select'. That's a > common misunderstanding. The 'poll' operation has that concept, but > 'select' does not. Could you explain us the standard, then? If the errorfds argument is not a null pointer, it points to an object of type fd_set that on input specifies the file descriptors to be checked for error conditions pending, and on output indicates which file descriptors have error conditions pending. |