Here you can find the source of createInetSocketAddress(final InetAddress address)
public static InetSocketAddress createInetSocketAddress(final InetAddress address)
//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); } }