I have a system where I get packets via TCPIP on port 9000(VPN) UDP on port 9000 (VPN) and TCPIP on port 6005 (not VPN)from multiple sources. Everything works well execpt every couple of nights I will stop receiving packets on port 9000 tcpip. no error occurs and i still receive udp on port 9000 and tcpip on port 6005. I start receiving again as soon as i restart the program. Is it possible to lock up TCPIP on a port but still allow pinging and udp taffic? Im using system threading could that be it?
Here is some code below, I'm wondering if i need some other way of clearing the port after i've received the packet.
Any suggestions are appreciated.
initalization
try
{
TcpThread = new Thread(new ThreadStart(TCP));
TcpThread.Start();
Console.WriteLine("Started TCP 9000 Thread V1!\n");
}
catch (Exception e)
{
Console.WriteLine("An Exception has occurred!" + e.ToString());
TcpThread.Abort();
}
try
{
// Start listening for client requests.
tcpListener.Start();
// Buffer for reading data
Byte[] bytes = new Byte[256];
String data = null;
while (true)
{
TcpClient client = tcpListener.AcceptTcpClient();
HeaderIP = client.Client.RemoteEndPoint.ToString();
Console.WriteLine("Packet received from : " + HeaderIP);
NetworkStream stream = client.GetStream();
int i;
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
data = data + System.Text.Encoding.ASCII.GetString(bytes, 0, i) ;
byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);
}
}
}
catch (SocketException e)
{
Console.WriteLine("TCPIP insertion Failed: {0}", e);
}
finally
{
tcpListener.Stop();
}
Here is some code below, I'm wondering if i need some other way of clearing the port after i've received the packet.
Any suggestions are appreciated.
initalization
try
{
TcpThread = new Thread(new ThreadStart(TCP));
TcpThread.Start();
Console.WriteLine("Started TCP 9000 Thread V1!\n");
}
catch (Exception e)
{
Console.WriteLine("An Exception has occurred!" + e.ToString());
TcpThread.Abort();
}
try
{
// Start listening for client requests.
tcpListener.Start();
// Buffer for reading data
Byte[] bytes = new Byte[256];
String data = null;
while (true)
{
TcpClient client = tcpListener.AcceptTcpClient();
HeaderIP = client.Client.RemoteEndPoint.ToString();
Console.WriteLine("Packet received from : " + HeaderIP);
NetworkStream stream = client.GetStream();
int i;
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
data = data + System.Text.Encoding.ASCII.GetString(bytes, 0, i) ;
byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);
}
}
}
catch (SocketException e)
{
Console.WriteLine("TCPIP insertion Failed: {0}", e);
}
finally
{
tcpListener.Stop();
}