|
Prev: Longines Ladies Watches DolceVita L5.155.4.84.6 - AA - Replica Watch Fake
Next: Bit bucket directory
From: Prabhu on 22 Apr 2008 10:33 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
From: Rainer Temme on 23 Apr 2008 12:44 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?
From: David Schwartz on 24 Apr 2008 16:50
On Apr 23, 9:44 am, Rainer Temme <Rainer_Te...(a)nospam.Hotmail_dot_Com> 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. DS |