TCP connect in Non Blocking Mode



Hi,

My client application tries to connect to the server in the following
manner:

...../
err = connect(sd, (struct sockaddr*) &sa, sizeof(sa));

if(err == -1)
{
if(errno == EINPROGRESS)
{
struct timeval l_connect_timeout;
int l_fds;
l_connect_timeout.tv_usec=0;
l_connect_timeout.tv_sec=30; //30 seconds.

while(1)
{
l_fds=select(sd+1, NULL,&filedes_set,NULL,
&l_connect_timeout);
if(l_fds == 0) //timed out
return 0;
else if(l_fds < 0) //select failed
return 0;
else
{
int l_sock_optval=-1;
int
l_sock_optval_len=sizeof(l_sock_optval);
if(getsockopt(sd,
SOL_SOCKET, SO_ERROR, (int*)&l_sock_optval,
(socklen_t*)&l_sock_optval_len) !=0)
{

return 0;
}

if(l_sock_optval == 0)
{
//connected to
server
break;
}
}

}

}

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?

Thanks,
Prabhu. S
.



Relevant Pages

  • RE: SSPI Kerberos for delegation
    ... you have to check on 'trust this machine for delegation' in the server computer's ADUC property page. ... Doing this will tell the client kerberos package that it should get a forwardable ticket and that it should forward it ... int n = ib.cbBuffer; ... // wserr() displays winsock errors and aborts. ...
    (comp.protocols.kerberos)
  • [NT] Dark Age of Camelot Man-In-The-Middle
    ... use of RSA public key cryptography and an RC4 based symmetric algorithm. ... Seeing the imminent release of code for cracking the game client (which ... At the beginning of each TCP session, the server sends a 1536 bit RSA ... void bytes_out(unsigned char *data, int len) ...
    (Securiteam)
  • echo client using threads
    ... pollwhile client is written using threads. ... server recvs some characters from a client and then echoes the ... int main ... exit(EXIT_FAILURE); ...
    (comp.unix.programmer)
  • Re: Problem with SslStream when using Windows Vista
    ... The code for the server & client follow. ... private int _port = 0; ... // SslStream using the client's network stream. ...
    (microsoft.public.dotnet.framework)
  • [UNIX] Multiple up-imapproxy DoS Vulnerabilities
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... connections open after client has logged out, ... allows attacker to cause the server to crash by sending them when they ... extern void HandleRequest(int); ...
    (Securiteam)