Click to See Complete Forum and Search --> : FD_CLOSE problem in Sockets


hinksj
December 12th, 2002, 06:11 PM
In Closing a Stream connection, I fail to receive the FD_CLOSE from the Server Side.

I am using Winsock2. ... NOT any version of MFC sockets.

I use WSAEventSelect to receive the event FD_CLOSE.

I as testing my code using both the Client side and Server side
in the same program and same computer.

Per all the documentation, I am trying for a graceful shut down of the socket connection instead of an aborted one.

I have a seperate thread that handles network events .... in this test it is doing both the Server and Client side processing.

Client issues shutdown(SD_SEND);

Network event thread receives FD_CLOSE for Server side socket.

Server side FD_CLOSE processing:
Issues shutdown(SD_SEND);
Loop until no data from rcv()
Issues socketclose();

I am expecting a FD_CLOSE to be received by the network thread for the Client socket based on the Server's shutdown()

The Client side FD_CLOSE NEVER appears!!!!

If I remove the socketclose from the Server side code .... all works well but I'm left with a unclosed socket on the Server side.

Is the problem that my test bed is the same computer/program??

Any insight please.

kuphryn
December 12th, 2002, 06:26 PM
I recommend calling closesocket() right after shutdown() if you know that the socket is not processing data.

Kuphryn