471,092 Members | 1,020 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

Networkstream Write problem

I have a TCP server to which a number of mobile devices connect. If a device
disconnects(mostly no clean close as they usually lose cell coverage or
shutdown), and the server then tries to send data using the
Networkstream.Write method, its NOT throwing an exception. I am using the
TCPClient class.
I am able to reproduce this by shutting down my test device(turning off
power) and then sending some data. The Write just finishes as if the data
was sent.
Is there some timeout that has to occur before the Write fails ?
Even the CanWrite returns true. Here is part of the code that writes

if (Cmd != "")
byte[] OTA = Encoding.ASCII.GetBytes(Cmd);
{ //JUst to check for connection }
catch (SocketException) //remote closed
catch(Exception eOTA)
Controller.EMailErr("OTA Send Error",eOTA.Message.ToString());
The mobile unit is a third party device and I just power it down to simulate
a lost TCP connection.I even used DataAvailable as it is supposed to throw
an exception if remote
disconnects. Even after I shutdown the remote device, the CanWrite returns
true and the Write does not thrown an exception.
The mobile unit connects using a wireless cellular network(ATT/cingular) -
would that have something to do with it ?


Srinivas Loka
Jul 21 '05 #1
0 1997

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Sven Huijbrechts | last post: by
7 posts views Thread by david.topham | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.