Re: Detect Disconnect in WinSock 2.0
- From: "Volodymyr M. Shcherbyna" <v_scherbina@xxxxxxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 13:35:09 +0100
You can poll socket by select(...) function in separate thread.
--
V
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Ahmad Jalil Qarshi" <ahmaddearNO@xxxxxxxxxxxxxxx> wrote in message
news:%23SkwiJXbIHA.5348@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I am using WinSock 2.0 library in my client/server application. I have to
confirm one thing.
If I call the connect function in my client application to connect with
the running server, connection is established successfully. Now if I stop
the server I can't get any intimation regarding the disconnection. So how
to detect the disconnection at client side?
In other case if after successful connection I try to send/receive data
to/from server and meanwhile the server stops this is handled gracefully.
Problem is only when connection is established and I am not going to
send/receive data for some time.
I have few solutions for that like:
1- Send some PING message and expect PONG in response to check if
connection is established or not after a specific time interval.
2- Start another thread that continuously wait for data to be received.
(i.e. call recv() function in a while loop) if failed to receive data send
Disconnect notification to main application.
But I want to know some better way to do that.
Any recommendations.
Regards,
Ahmad Jalil Qarshi
.
- Follow-Ups:
- Re: Detect Disconnect in WinSock 2.0
- From: Ahmad Jalil Qarshi
- Re: Detect Disconnect in WinSock 2.0
- References:
- Detect Disconnect in WinSock 2.0
- From: Ahmad Jalil Qarshi
- Detect Disconnect in WinSock 2.0
- Prev by Date: Detect Disconnect in WinSock 2.0
- Next by Date: Re: Detect Disconnect in WinSock 2.0
- Previous by thread: Detect Disconnect in WinSock 2.0
- Next by thread: Re: Detect Disconnect in WinSock 2.0
- Index(es):
Relevant Pages
|