Code example for InetSocketAddress

Methods: isUnresolved

  public TcpClient(String host, int port, RemoteClient parent) throws IOException, IllegalArgumentException {
    ui = parent;
    // Open connection : 
    sock = new Socket();
    InetSocketAddress adress = new InetSocketAddress(host, port);
    if (adress.isUnresolved()) {
      Log.d(LOGTAG, "Adress is unresolved");
      throw new IllegalArgumentException("Bad adress");
    sock.connect(adress, 1000);
    sender = new Sender(sock);
    receiver = new Receiver(sock);
    serverPort = port;
    serverUrl = host;
  public int getPort() { 
    return serverPort;
Connect your IDE to all the code out there  Get Codota for Java