Re: How can I tell when a remote TCP connection is closed?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jim H wrote:

I have a client with a TCP connection to a server. Without using events (I need the code to be portable), is there a way that I can tell if the remote end has closed the connection without performing a read or a write on the socket? I tried doing a select for an error condition but it times out. Select on readable or writeable always return as if the remote end is still connected.

select() on readable WILL return true if the server has closed the TCP connection gracefully, so perhaps you have something else wrong with your code?


The remote end is doing a shutdown and close on the socket. Netstat shows close_wait. I need to know if the connection has been dropped without having a read or write fail.

After select() returns true for readable, then the recv() will fail with the error. That is the ONLY way to do it.


Can anyone help me out with this?
>
Thanks in advance,
jim

-- Phil Frisbie, Jr. Hawk Software http://www.hawksoft.com .



Relevant Pages

  • Re: Connecting a remote workstation to a domain
    ... If you have more than a couple of remote workstations connecting to the SBS ... server via VPN, you really need to consider a Terminal Server in the main ... "Log in using a dial up connection" checkbox, ... roaming profile then synchronizes with the server over the VPN); ...
    (microsoft.public.windows.server.sbs)
  • Re: Connecting a remote workstation to a domain
    ... I can remotely join XP Pro computers at the remote ... connection" checkbox so that any user can logon remotely. ... "Log in using a dial up connection" checkbox, either way it loads her cached ... roaming profile then synchronizes with the server over the VPN); ...
    (microsoft.public.windows.server.sbs)
  • Re: autoRepeating Error log ID 20111 (Remote Access)
    ... PPPoE connection software on the server turns what could/should be a full ... >> A Demand Dial connection to the remote interface Small Business ... >> Event Type: Warning ... >> Event Source: MSSQL$SBSMONITORING ...
    (microsoft.public.windows.server.sbs)
  • RE: Remote Office Configuration Suggestions?
    ... Welcome to SBS newsgroup. ... I understand that you want to keep the remote office continue working even ... after the main internet connection on the main office is not available. ... If you want to join the remote server to a SBS domain and become a member ...
    (microsoft.public.windows.server.sbs)
  • Re: Problem with Web based client
    ... Seems like you are having problems accessing the web server on the PC you ... > My remote desktop connection works fine when I connect with a Remote ...
    (microsoft.public.windowsxp.work_remotely)