C# : How to set test TCP connection timeout?
- by Prince OfThief
I try to test TCP connection with the following code.
System.Threading.Thread t = new System.Threading.Thread(() =>
{
using (TcpClient client = new TcpClient())
{
client.Connect(ip, Convert.ToInt32(port));
}
}
});
t.Start();
How to set time out if the ip or port is invalid?