IAsyncResult ar = tcpClient.BeginConnect(ip,port,null,null);
bool success = ar.AsyncWaitHandle.WaitOne(1000);
if (!success)
throw new Exception("超时时间已到,未连接到指定服务器");
C#TCP连接超时
最新推荐文章于 2024-04-25 07:09:17 发布
IAsyncResult ar = tcpClient.BeginConnect(ip,port,null,null);
bool success = ar.AsyncWaitHandle.WaitOne(1000);
if (!success)
throw new Exception("超时时间已到,未连接到指定服务器");