是否有可能设置超时如下?:的System.Net.Sockets - 定义超时? (C#)
try
{
System.Net.Sockets.Socket sock = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);
sock.Connect(ipa, portno1);
if (sock.Connected == true) // Port is in use and connection is successful
{
displayGreen1();
}
sock.Close();
}
这是重复http://stackoverflow.com/questions/456891/how-do-i-set-the-time-out-of-a-socket-connect-call – robowahoo