A
Anatoly
In our application I need to detemine if there is a internet connection
valid.
So I build a windows service which every minute creates telnet connection
against some host and port.
If I do connect to this host I know that internet connection is OK.
The problem: after few days CPU usage growing up to 50% for this service.
After restart it's problem gone for another 2,3 days.
This is a code:
public static bool IsBrowseable(string IP, int Port)
{
bool Result = false;
try
{
IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(IP), Port);
Socket m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
m_Socket.Connect(localEP);
Result = m_Socket.Connected;
m_Socket.Close();
}
catch (Exception E)
{
Utils.ProcessError("something wrong", E);
Result = false;
}
return Result;
}
Please help to find the problem.
Thanks
valid.
So I build a windows service which every minute creates telnet connection
against some host and port.
If I do connect to this host I know that internet connection is OK.
The problem: after few days CPU usage growing up to 50% for this service.
After restart it's problem gone for another 2,3 days.
This is a code:
public static bool IsBrowseable(string IP, int Port)
{
bool Result = false;
try
{
IPEndPoint localEP = new IPEndPoint(IPAddress.Parse(IP), Port);
Socket m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
m_Socket.Connect(localEP);
Result = m_Socket.Connected;
m_Socket.Close();
}
catch (Exception E)
{
Utils.ProcessError("something wrong", E);
Result = false;
}
return Result;
}
Please help to find the problem.
Thanks