I am currently trying to (sucessfully) connect and
disconnect a Client-Server socket connection using
Windows/Visual C++.
The connection seems to happen without problems, but the
disconnect does not go as gracefully. Background: the
client socket is blocked on a recv() call in one thread,
and I am trying to disconnect gracefully via a second
thread. In the second thread, I am initiating a
disconnect on the Client side by first setting the LINGER
options to a graceful disconnect:
LINGER linger;
linger.l_onoff = 1;
linger.l_linger = 0;
dwError = setsockopt ( m_hSocket, SOL_SOCKET,
SO_LINGER, (char *) &
linger, sizeof ( linger ) );
if ( dwError == SOCKET_ERROR )
{
TRACE ("Set Socket opt error \n");
}
}
}
then calling closesocket () to shutdown the socket:
if(closesocket(m_hSocket) == SOCKET_ERROR)
{
ErrorHandler( &dwError , ErrStr );
}
This results in the error WSAECONNABORTED (saying that
software caused connection abort). I have tried various
things to remedy this, such as waiting inbetween the calls
to "flush" things out, calling shutdown() in between, but
these do not seem to affect anything. Any suggestions or
insight would be greatly appreciated.
Cheers,
Jan
JanO <jan_...@agilent.com> wrote in message
news:275701c1f86e$af439f20$3bef2ecf@TKMSFTNGXA10...