Windows Server TCP Client application in c# Stops working after a while
Posted
by
user1692494
on Stack Overflow
See other posts from Stack Overflow
or by user1692494
Published on 2012-09-23T15:33:12Z
Indexed on
2012/09/23
15:37 UTC
Read the original article
Hit count: 287
c#
|service-application
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.
© Stack Overflow or respective owner