Re: Detecting Disconnect on TCP Socket
From: David Sworder (dsworder_at_cts.com)
Date: 05/13/04
- Next message: Bjorn Abelli: "Re: override by name in c#?"
- Previous message: Konrad L. M. Rudolph: "Re: CSV files"
- In reply to: AlexS: "Re: Detecting Disconnect on TCP Socket"
- Next in thread: AlexS: "Re: Detecting Disconnect on TCP Socket"
- Reply: AlexS: "Re: Detecting Disconnect on TCP Socket"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Bjorn Abelli: "Re: override by name in c#?"
- Previous message: Konrad L. M. Rudolph: "Re: CSV files"
- In reply to: AlexS: "Re: Detecting Disconnect on TCP Socket"
- Next in thread: AlexS: "Re: Detecting Disconnect on TCP Socket"
- Reply: AlexS: "Re: Detecting Disconnect on TCP Socket"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|