C#TCP连接超时

IAsyncResult ar = tcpClient.BeginConnect(ip,port,null,null;
bool success = ar.AsyncWaitHandle.WaitOne(1000);
if (!success)
throw new Exception("超时时间已到,未连接到指定服务器");

你可能感兴趣的:(C#)