C# : How to set test TCP connection timeout?

Posted by Prince OfThief on Stack Overflow See other posts from Stack Overflow or by Prince OfThief
Published on 2011-01-03T10:58:34Z Indexed on 2011/01/04 7:54 UTC
Read the original article Hit count: 322

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about connection