Socket tcp connection
<p>I'm developing an application on android studio. I'm trying to  open a socket connection.</p>

<p>When the user enters the right IP address, everything works fine, but  if the address is not the right IP, the <code>Socket</code> is not connected.</p>

<p>But the problem is that the <code>Socket</code> does not throw an catch <code>Exception</code>, the app is running and now if the user enters  the right ip address, the socket is not connected.</p>

<p>My question is why it does not throw an catch <code>Exception</code> if the IP address is not the right IP and how can I make it work? </p>

<p>Here is the code </p>

<pre><code>   try {
        sockettcp = new Socket(Address, Port);
    } catch (Exception e) {
        valid = false;
    }
</code></pre>