Winsock TCP Client disconnect
-
I have a question. Are these same? 1. Close the client application window. [ Closes the stream ], (Server gets out of the below block)
do { n=recv(client,buff,MAX_BUFF_SIZE,0); if(n==SOCKET_ERROR ) { break; } }while()
2. UnPlug the client's network cable. [should close the stream?] , server never gets notified? it never happens. WTF??? :wtf: :confused: I'm not able to detect the latter one. Please help. If the n/w cable is unplugged, the stream would be broken and it should fire a sock exception right?:~
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
I have a question. Are these same? 1. Close the client application window. [ Closes the stream ], (Server gets out of the below block)
do { n=recv(client,buff,MAX_BUFF_SIZE,0); if(n==SOCKET_ERROR ) { break; } }while()
2. UnPlug the client's network cable. [should close the stream?] , server never gets notified? it never happens. WTF??? :wtf: :confused: I'm not able to detect the latter one. Please help. If the n/w cable is unplugged, the stream would be broken and it should fire a sock exception right?:~
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
Hi, the value from SOCKET_ERROR is -1 if you unplug the network recv will be return 0 Change your code to
do { n=recv(client,buff,MAX_BUFF_SIZE,0); if(1 > n) { break; } }while();
HTH FrankNope! :( It doesn't work. The disconnection is not detected. Please help.
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
-
I have a question. Are these same? 1. Close the client application window. [ Closes the stream ], (Server gets out of the below block)
do { n=recv(client,buff,MAX_BUFF_SIZE,0); if(n==SOCKET_ERROR ) { break; } }while()
2. UnPlug the client's network cable. [should close the stream?] , server never gets notified? it never happens. WTF??? :wtf: :confused: I'm not able to detect the latter one. Please help. If the n/w cable is unplugged, the stream would be broken and it should fire a sock exception right?:~
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.
TCP does _not_ maintain a connection, it only maintains information about the connection. Unplugging the cable merely prevents data from moving. You need to implement a ping or timeout type feature in your protocol if you want to be notified if/when the cable is unplugged. See: http://tangentsoft.net/wskfaq/newbie.html#abnormalclose[^]
...cmk Save the whales - collect the whole set
-
TCP does _not_ maintain a connection, it only maintains information about the connection. Unplugging the cable merely prevents data from moving. You need to implement a ping or timeout type feature in your protocol if you want to be notified if/when the cable is unplugged. See: http://tangentsoft.net/wskfaq/newbie.html#abnormalclose[^]
...cmk Save the whales - collect the whole set
Thanks for the link!! I just stopped tussling with the issue. Implementing a sensor now ;)
--[:jig:]-- [My Current Status] Link2006 wrote:Let's take it outside of CP Jeremy : Please don't.I would love to see this.I'm making the popcorn already.