Re: TCP connect in Non Blocking Mode



David Schwartz wrote:
On Apr 23, 9:44 am, Rainer Temme <Rainer_Te...@xxxxxxxxxxxxxxxxxxxxxx>
wrote:
Prabhu wrote:
err = connect(sd, (struct sockaddr*) &sa, sizeof(sa));
....
l_fds=select(sd+1, NULL,&filedes_set,NULL,&l_connect_timeout);
This works fine. The issue that I face is when the server refuses
connection by sending RST for the SYN from client. The select waits
for 30 seconds and later returns timing out. RST though is sent
immediately by the server. The client application need to capture the
RST as soon as it arrives. How do we achieve that. Why does not the
select return immediately when the RST arrives at client?
Have you tried to select() the filedescriptor for read (in the
read-fd-set) as well?

He's trying to connect. Checking for readability doesn't make sense
unless he has nothing else to do until the other side sends him any
data.

Acutally, select() poll() do NOT check for readablity but for
the ability to call read() without being blocked in the call.
Since the connection is refused by the RST, read() should
return iommediately with result -1 and errno set to ECONNREFUSED.
And select() should indicate that a read() can be called without
being blocked.

Rainer
.



Relevant Pages

  • Re: Question regd timestamp option
    ... > RST Following this RST, the client comes back in lets say around ... Now if you open a second connection, while things are still OK, do you see the ... connections to the server? ...
    (freebsd-net)
  • Re: TCP reset caused by socket.py
    ... with the connection, usually a half-open connection. ... | Reset Generation ... Instead I see the server send data to the client and then a RST, ...
    (comp.lang.python)
  • Re: Socket weirdness
    ... If RST is at the top of the stack before the ... RST is not "seen" by the client until the first ACK to client *after ... a Shutdown.Receive by the server. ... some N factor of stocks or time and closes socket. ...
    (microsoft.public.dotnet.framework)
  • RE: CAsyncSocket performing RST on Connect()
    ... I have a windows client that opens a tcp connection and sometimes ... the connection underneath sends a RST just like in your trace. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Response of listening socket when queue of pending connections is full
    ... If I had had control over the client end of the software, ... >I would have designed it to re-attempt the connection later, ... On Windows, for some reason, the TCP stack responds with a RST, which is ...
    (microsoft.public.win32.programmer.networks)