Windows Server TCP Client application in c# Stops working after a while
- by user1692494
I am developping an application in C# Net framework 2.0.
It is basicly a service application with a tcp client class.
Class for Tcp Client Part
public TelnetConnection(string Hostname, int Port)
{
host = Hostname;
prt = Port;
try
{
tcpSocket = new TcpClient(Hostname, Port);
}
catch (Exception e)
{ //Console.WriteLine(e.Message); }
}
The application is connecting to the server and revieves update's and more information.
It works for about 20 minutes then stops recieving information from the server.
-- Server side Client is still connected
and the client side its still connected but stops receiving information from the server.
I've been searching Stack Overflow and Google but no luck.
try
{
if (!tcpSocket.Connected) return null;
StringBuilder sb = new StringBuilder();
do
{
Parse(sb);
System.Threading.Thread.Sleep(TimeOutMs);
} while (tcpSocket.Available > 0);
return sb.ToString();
}
Application works perfect when it runs as console application but when running as service.
It just stops.