0

Socket requestSocket = new Socket(a, 6666);

When I try to connect with serwer and server is unavailable I gave to wait 1 min or more to see 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.navigationdrawerexample W/System.err:     at libcore.io.IoBridge.connect(IoBridge.java:114)

How can I set lower time to try connect with server ?

  • you can set a timeout on connect read this: [https://stackoverflow.com/questions/4969760/setting-a-timeout-for-socket-operations](https://stackoverflow.com/questions/4969760/setting-a-timeout-for-socket-operations) – toien Sep 14 '17 at 06:42

1 Answers1

1

I suppose you're using Socket.connect(SocketAddress) method. There is another Socket.connect(SocketAddress, int) where you can specify timeout as the second parameter. Hope it helps!

Sergey Prokofiev
  • 1,815
  • 1
  • 12
  • 21