Java套接字等待超过1分钟以尝试连接服务器
Socket requestSocket=新Socketa,6666 当我尝试连接serwer,但服务器不可用时,我会等待1分钟或更长时间才能看到jaJava套接字等待超过1分钟以尝试连接服务器,java,sockets,Java,Sockets,Socket requestSocket=新Socketa,6666 当我尝试连接serwer,但服务器不可用时,我会等待1分钟或更长时间才能看到ja va.net.ConnectException: failed to connect to /192.168.43.50 (port 6666): connect failed: ETIMEDOUT (Connection timed out) 09-14 08:36:02.705 3244-3345/net.simplifiedcoding.n
va.net.ConnectException: failed to connect to /192.168.43.50 (port 6666): connect failed: ETIMEDOUT (Connection timed out)
09-14 08:36:02.705 3244-3345/net.simplifiedcoding.navigationdrawerexample W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:114)
如何设置较短的时间来尝试连接服务器?我想您正在使用此方法。还有一种方法可以将timeout指定为第二个参数。希望有帮助 您可以在连接时设置超时,请阅读以下内容: