Here you can find the source of getInetSocketAddress(long addrAsInt32, int port)
public static InetSocketAddress getInetSocketAddress(long addrAsInt32, int port)
//package com.java2s; /*//from w w w . java 2s.c om * OpenFire - a Java API to access the XFire instant messaging network. * Copyright (C) 2007 Iain McGinniss * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ import java.net.Inet4Address; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; public class Main { public static InetSocketAddress getInetSocketAddress(long addrAsInt32, int port) { return new InetSocketAddress(getAddressFromInt32(addrAsInt32), port); } public static Inet4Address getAddressFromInt32(long value) { byte[] address = new byte[4]; address[0] = (byte) (value >> 24); address[1] = (byte) (value >> 16); address[2] = (byte) (value >> 8); address[3] = (byte) (value); try { return (Inet4Address) InetAddress.getByAddress(address); } catch (UnknownHostException e) { // will never happen as we know the byte array we have passed // is the correct length for IPv4 throw new RuntimeException("UnknownHostException unexpectedly thrown", e); } } }