SCTP Socket not getting closed when close is called after sleep,without sleep it works fine

Submitted by praveen24
on January 14, 2010 - 4:57am

I have this code --------
-----------------------------------------
sleep(1); //calling sleep
if(_fd != 0) {
struct linger lin;
lin.l_onoff = 1;
lin.l_linger = 0;
int ret = setsockopt(_fd, SOL_SOCKET, SO_LINGER, &lin, sizeof(lin));
if(ret < 0) {
perror("SO_LINGER : ");
}
cout << "LINGER CLOSE ON FD = " << _fd << endl;
close(_fd); //Calling close

--------------------------------------------
I call simply sleep and set SO_LINGER option and closes this end----but it is not closing and doesnot send any shutdown message to server side-----but If I remove sleep from the code it works fine-----any reason?

looks like somebody else is

Anonymous (not verified)
on
January 19, 2010 - 4:36am

looks like somebody else is closing the fd.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.