Re: Detect Disconnect in WinSock 2.0

Tech-Archive recommends: Speed Up your PC by fixing your registry



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



.



Relevant Pages

  • Re: a problem with Socket
    ... now the problem with the connection is solved: when the server was ... listening and I closed the connection, I didn't call ServerSocket.close, ... I would like not to use a separate thread ...
    (comp.lang.java.programmer)
  • Re: Detect Disconnect in WinSock 2.0
    ... the server I can't get any intimation regarding the disconnection. ... to detect the disconnection at client side? ... In other case if after successful connection I try to send/receive data ...
    (microsoft.public.win32.programmer.networks)
  • Detect Disconnect in WinSock 2.0
    ... If I call the connect function in my client application to connect with the ... server I can't get any intimation regarding the disconnection. ... In other case if after successful connection I try to send/receive data ...
    (microsoft.public.win32.programmer.networks)
  • Re: a problem with Socket
    ... Looks like you are looking to build an tcp server in java.. ... > listening and I closed the connection, I didn't call ServerSocket.close, ... >> On the other hand, if there will only be a single connection, there is ... I would like not to use a separate thread ...
    (comp.lang.java.programmer)
  • Threading with server
    ... I would use TcpListener class 's BeginAcceptSocket method. ... let me assign separate thread for each connection. ... In this scenario I want to include time-out feature i.e. server will ... close connection it will be in waiting state for longer time. ...
    (microsoft.public.dotnet.languages.csharp)