title: What will happen to a TCP/UDP serversocket when I switch wifi network?
body: <p>what will happen to the serversocket in my app when I suddenly change the wifi network? I guess it will shut down since my device will get a new IP, at least in TCP, is the UDP MulticastSocket prone to this as well? And how to end the previous Server socket thread and start a new one when the network changes? One solution is using time outs, another is using a flag that will indicate whether the infinite loop should end or not but since listening to a socket is a blocking function it will produce an exception/error anyways.</p>
  
  <p>Any thoughts will be appreciated! :)</p>
  
  <p><strong>EDIT:</strong> sample of my server thread.</p>
  
  <pre><code>ServerSocket ss = new ServerSocket(4445);
  while(true){
      Socket socket = ss.accept();
      ObjectInputStream in  = new ObjectInputStream(socket.getInputStream());
      Object obj = in.readObject();
      Log.i("TAG", "Received: " + obj.toString());
      in.close();
      socket.close();
  }
  </code></pre>