Java Socket Address Get getInetSocketAddress(String s, String mainHost)

Here you can find the source of getInetSocketAddress(String s, String mainHost)

Description

get Inet Socket Address

License

Open Source License

Declaration

private static InetSocketAddress getInetSocketAddress(String s, String mainHost) 

Method Source Code


//package com.java2s;
import java.net.InetSocketAddress;

public class Main {
    private static InetSocketAddress getInetSocketAddress(String s, String mainHost) {
        int finalColon = mainHost.lastIndexOf(':');
        if (finalColon < 1) {
            throw new IllegalArgumentException("Invalid server ``" + mainHost + "'' in list:  " + s);

        }//from w w w . j a  v  a  2s.c o  m
        String hostPart = mainHost.substring(0, finalColon).trim();
        String portNum = mainHost.substring(finalColon + 1).trim();

        InetSocketAddress mainAddress = new InetSocketAddress(hostPart, Integer.parseInt(portNum));
        return mainAddress;
    }
}

Related

  1. getInetSocketAddress(long addrAsInt32, int port)
  2. getInetSocketAddress(String addressPortStr, int defaultPort)
  3. getInetSocketAddress(String arg)
  4. getInetSocketAddress(String endpoint)
  5. getInetSocketAddress(String endpointURI, int defaultPort)
  6. getInetSocketAddressFromStringStrict(String s)
  7. getInetSocketTransportAddressConstructor()
  8. getIp(SocketAddress socketAddress)
  9. getIpAddress(Socket socket)