Ihave code below with about 300 clint all clint send gps location every 15 min after 2 or 3 hour delay happening to tcplistener
code plow
public static void Main()
{
TcpListener server = null;
Int32 port = 556;
System.Net.IPAddress localAddr = IPAddress.Parse("192.168.1.2");
server = new TcpListener(localAddr, port);
// StartTcpListener listening for client requests.
try
{
server.Start();
//int count = 0;
// Enter the listening loop.
while (true)
{
Console.Write("Waiting for a connection... \n");
// Perform a blocking call to accept requests.
TcpClient client = server.AcceptTcpClient();
var childSocketThread = new Thread(() =>
{
// Buffer for reading data
Byte[] bytes = new Byte[256];
String data = null;
data = null;
NetworkStream stream = client.GetStream();
int i;
try
{
// Loop to receive all the data sent by the client.
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0 )
{
data = ByteArrayToHexString(bytes);
processData(data);
data = "";
} client.Close();
}
catch (Exception ex)
{
stream.Dispose();
client.Close();
stream.Flush();
server.Stop();
Main();
}
}
);
childSocketThread.Start();
}
}
catch (Exception e)
{
server.Stop();
return;
}
finally
{
try
{
server.Stop();
}
catch (Exception e)
{
Console.WriteLine("SocketException2: {0}", e.ToString());
}
}
Console.WriteLine("\nHit enter to continue...");
//Main();
Console.Read();
}