Re: Graceful socket cleanup problem
Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance
Put recv() between shutdown() and closesocket()
Arkady
"Nadav" <Nadav@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:81FF1733-5BF1-462C-8F49-DF297A253106@xxxxxxxxxxxxxxxx
Hi,
I have implemented a P2P application that use IO Completion port
associated
with a thread pool for async network communication.
Graceful connection termination is done in the following way:
A.shutdown(m_socket, SD_SEND);
B.closesocket(m_socket)
calling shutdown causes the pending completion requests for the peer
socket
to return with 0 == ?dwNumBytes?, this indicate the peer of connection
termination and cause the peer to repeat the same cleanp flow ( shutdown &
closesocket ), surprisingly, the host socket ( the one that initially shut
down the socket ) doesn?t get it?s pending completion requests return with
0
== ?dwNumBytes?, actually these completion requests doesn?t return at-all?
why does it happen? What am I doing wrong here?
Any help would be appreciated.
--
Nadav
http://www.sophin.com
.
Relevant Pages
- Re: close and O_NONBLOCK on TCP/IP socket in Linux
... >> reading what i am interested in from the peer. ... If they don't read, but only write, then they won't see FIN, and ... >> to report the FD as writable after nonblocking shutdown of write?. ... OP the socket is closed after he got what he wanted. ... (comp.unix.programmer) - Re: closing ASyncSocket
... I reread the help for the ShutDown() call. ... not close the socket, and resources attached to the socket will not be freed ... What if I want to Closethe connection to return resources. ... receiving side after I received the last data. ... (microsoft.public.vc.mfc) - RE: Does Socket.Shutdown or Socket.Close Block and when?
... receive a heartbeat message every 5 seconds on each socket (to make sure the ... connection is still up to each client). ... heartbeat within say 10 seconds then the server will proceed to shutdown the ... the send buffer is empty or becomes empty before the elapsed timeout. ... (microsoft.public.dotnet.languages.csharp) - Re: Socket connect/disconnect, ReuseAddress, and TIME_WAIT
... Shutdown and Close is the way to close a socket. ... you won't be able to accept a connection from the same client that was connected when the previous connection was reset. ... The better solution is simply to make sure that your connections go through a graceful shutdown before closing the socket, ... (microsoft.public.dotnet.languages.csharp) - TCP socket, shutdown, eats last few bytes in buffer (rarely)
... Open input and output TCP sockets. ... However every so often the shutdown() seems to eat whatever the lat writesent to the transmission buffer, such that the next node never receives it. ... Shouldn't shutdownused this way on a TCP socket wait until the ... DEBUG closing fd 8 type A <-- this is where the shutdownis called ... (comp.unix.programmer) |
|