Re: Detecting Disconnect on TCP Socket

From: David Sworder (dsworder_at_cts.com)
Date: 05/13/04


Date: Thu, 13 May 2004 10:04:09 -0700

Hi Alex,

> it's not always like this. I've seen situations when endreceive delivered
0
> bytes, however beginreceive issued at that point was getting more data. It
> really depends on how remote end behaves. If remote server is slow - you
can
> get 0 bytes while there are data available.

    Are you sure about this? I just double-checked the documentation for
EndReceive() and it looks like a return value of 0 indicates that the remote
system has Shutdown the connection.

    Consider an example where a client connects to a server and doesn't send
any data for five minutes. The server calls BeginReceive() immediately after
the connection is accepted. The first callback won't be even be made for 5
minutes. When the callback is finally made, there will be at least 1 byte of
data to receive. In other words, EndReceive() should return a value greater
than zero. If for some reason the client terminates early (say after two
minutes), the callback will be made and the server's EndReceive() call will
return zero. At that point, are you saying that it's possible for further
data to be in the pipeline? I wouldn't have thought that this is the case
since the socket is already shutdown. I would think that the socket should
immediately be closed and disposed at this point.

> If you know what you should get from remote server you can check if you
got
> everything, for example using end-of-file byte or some tag line. I've seen
> situations when I was receiving 5-10MB in chunks of 100-200K with delays
of
> several seconds between chunks.

    ...but your EndReceive() should never have returned zero between chunks,
right? If it did, wouldn't this imply that the client had dropped the
connection?

David



Relevant Pages

  • Accessing .mdb data from a remote computer on a non asp application
    ... have fount which fits to my application is changing the connection ... ("noa-second" is the machine where the MDB file is located) ... when I use the second one (with the remote) I get the error: ... adding http:// to the Remote Server sends error "count not connect to ...
    (comp.databases.ms-access)
  • Re: SMTP Errors in Event log
    ... It could however also be networking problems on the remote side. ... > 1) Message delivery to the host 'XXX.XXX.XXX.XXX' failed while delivering ... > the remote domain 'XXXXXXX.com' for the following reason: The connection ... > the remote domain 'XXXX.com' for the following reason: The remote server ...
    (microsoft.public.inetserver.iis.smtp_nntp)
  • Re: Will killing tty stop remote jobs started by that session?
    ... That rsync is between two remote servers...not my PC. ... behind a 1Mbps connection), so IF my closing my PC's connection to the ... remote server does stop the job, I REALLY don't want to have wasted ...
    (comp.os.linux.misc)
  • RMI thru Internet
    ... Im using RMI to connect java applet with a remote server. ... but its failed when try to establish connection through the Internet. ...
    (comp.lang.java.programmer)
  • 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)