Java InetAddress createInetSocketAddress(final InetAddress address)

Here you can find the source of createInetSocketAddress(final InetAddress address)

Description

create Inet Socket Address

License

Open Source License

Declaration

public static InetSocketAddress createInetSocketAddress(final InetAddress address) 

Method Source Code

//package com.java2s;
/**//w  w w.  ja  va  2s . c  o  m
 * Copyright 2015 Smart Society Services B.V.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 */

import java.net.InetAddress;
import java.net.InetSocketAddress;

public class Main {
    private static int CLIENT_PORT = 12121;
    private static int LOCAL_CLIENT_PORT = 12123;

    public static InetSocketAddress createInetSocketAddress(final InetAddress address) {
        if (address.isLoopbackAddress()) {
            return new InetSocketAddress(address, LOCAL_CLIENT_PORT);
        }

        return new InetSocketAddress(address, CLIENT_PORT);
    }
}

Related

  1. convertInetAddressToLong(InetAddress addr)
  2. convertInetAddressToLong(InetAddress address)
  3. convertLongToInetAddress(long address)
  4. createAbsoluteURL(InetAddress address, int localStreamPort, URI relativeOrNot)
  5. createDatagramSocket(InetAddress addr, int port)
  6. createResolved(InetAddress address, int port)
  7. createSocket(InetAddress address, int port, boolean fixedPort)
  8. doMatch(InetAddress inetAddress, String toMatchParam)
  9. findFreePort(InetAddress address, int start, int end)