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
looks like somebody else is closing the fd.