I have mobile RF terminal with Windows CE 6.0 CF 3.5 and I need send data as quickly as possible to my server. Problem is that wifi connection is not stable enough in place of use. I reduced the loss of data with repeated sending when connection is aborted by exception. But time for exception is ~21sec and it's too long for me. Repeated connections are successful (mostly), but I need shorten time for exception, or find different method for connection.
For data receive I have TCP server in terminal. And here I have one thread with timer and after my timeout I close client (TcpClient) and catch exception from this :-). But I mean that this method is not ideal.
Any ideas?? Thanks!
Below is my code for TCP client connection
internal string TCPsend(string strMessage)
{
string exception = string.Empty;
TcpClient client = null;
try
{
client = new TcpClient(IPServer, PortServer);
client.SendTimeout = 500; //no effect
Stream stream = client.GetStream();
StreamWriter strWriter = new StreamWriter(stream);
strWriter.Write(strMessage);
strWriter.Close();
}
catch (Exception ex)
{
exception = ex.ToString();
utility.SaveExceptionLog("SendTCP A: " + ex.ToString());
}
finally
{
if (client != null)
{
client.Close();
}
}
return exception;
}