GetStream.Read behavior changed in .Net 2.0 with respect to ReceiveTimeout



Hi,

I've noticed that the behavior of ReceiveTimeout has changed
between .Net 1.1 and .Net 2.0 when it comes to the GetStream.Read
method. In .Net 1.1, if the timeout period elapsed, I would get a
System.IO.IOException, but the connection stayed open. I could then
check the InnerException for Errorcode 10060 to verify that it was a
timeout. In .Net 2.0, I still get an IOException when there's a
timeout, but this time the socket closes. This means I would have to
reestablish the connection when I didn't need to before (or worse yet,
if I'm not controlling the connection, then I have to wait for the
other end to reconnect. Is there a way to avoid the disconnects?

Below is some sample code


m_tcpClient.ReceiveTimeout = 5000
try
intCount = m_tcpClient.GetStream.Read(bytData, 0, DATA_SIZE)
If intCount > 0 Then
'Got data
Else
'intCount = 0 means the connection was closed at the other end
ShowMessage("Lost connection")
blnReset = True
End If
Catch ex As System.IO.IOException
If TypeOf ex.InnerException Is SocketException AndAlso
CType(ex.InnerException, SocketException).ErrorCode = 10060 Then
'This should mean that we had a timeout
'for some reason, in .Net 2.0 I am getting a disconnect after a
timeout. For now, reset connection
End If
end try

thanks,
Keith Langer

.



Relevant Pages

  • Re: OE6 does not connect with pop3 server
    ... Can we infer from this that you got a timeout on the EarthLink account ... My point about making an approximate timestamp is just to look at the ... E.g. as near as possible before the connection ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Timout control with RPC/HTTP
    ... specifies the minimum connection timeout used by the ... client and RPC Proxy, in seconds. ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.exchange.admin)
  • Re: Timout control with RPC/HTTP
    ... please also check the RPC web site connection timeout settings ... Maybe the idle timeout settings depend on here. ...
    (microsoft.public.exchange.admin)
  • Re: web serivce: client side timeout?
    ... client side but only from the server side. ... System.Net.Sockets.SocketException: A connection attempt failed ... asyncResult, Int32 timeout, Exception& exception) ... John Saunders | MVP - Windows Server System - Connected System ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Timout control with RPC/HTTP
    ... But it is a IDLE timeout period that I am looking to control. ... But when they are idel the connection status will say - " last updated ...." ... Where do I control the settings for outlook to reconnect to the server to see if the mailbox is in sync with the remote lcoal cache. ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.exchange.admin)

Loading