public void connect(SocketAddress endpoint,int timeout);
可以用这个试试,设置timeout时间,是毫秒级的。如:
try{
Socket socket =new Socket();
InetSocketAddress inetSocketAddress=new InetSocketAddress("172.1.1.1",55962);
socket.connect(inetSocketAddress,2000);
}catch(Exception e){
e.printStackTrace();
}等待2秒把。
可以用这个试试,设置timeout时间,是毫秒级的。如:
try{
Socket socket =new Socket();
InetSocketAddress inetSocketAddress=new InetSocketAddress("172.1.1.1",55962);
socket.connect(inetSocketAddress,2000);
}catch(Exception e){
e.printStackTrace();
}等待2秒把。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货