关于JAVA中线程启动SOCKET中的异常处理问题,望各位提出宝贵建议_百度...
发布网友
发布时间:2022-05-05 02:11
我来回答
共2个回答
热心网友
时间:2022-04-13 23:21
加try catch 捕获那个异常,延时再检查网络后再重连
Ping
//using System.Net;
NetworkInformation.Ping p = new NetworkInformation.Ping();
NetworkInformation.PingOptions options = new NetworkInformation.PingOptions();
options.DontFragment = true;
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
//Wait seconds for a reply.
int timeout = 4000
NetworkInformation.PingReply reply = p.Send(%%1, timeout, buffer, options);
%%2=reply.Status;
热心网友
时间:2022-04-14 00:39
你可以加给try catch 捕获那个异常,一旦出现异常,在catch里重新连接,如果连接失败,再给个提示