title: How to prevent application freeze if server unavailable?
body: <pre><code>InetAddress serverAddr = InetAddress.getByName(serverAddress);
  String hostname = serverAddr.getCanonicalHostName();
  Socket socket = new Socket(serverAddr, portNumber);
  // Freezes before this line if the server is unavailable
  socket.setSoTimeout(3000);
  </code></pre>
  
  <p>Does anyone know how to implement the check of server availability or prevent the freezing?</p>