Here you can find the source of isBound(int port)
public static boolean isBound(int port) throws Exception
//package com.java2s; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; public class Main { /**//from w w w.j av a2 s . c o m * Returns true if port is already bound by * a process; otherwise returns false. */ public static boolean isBound(int port) throws Exception { InetSocketAddress address = new InetSocketAddress(port); return isBound(address); } /** * Returns true if ip+port are already bound by * a process; otherwise returns false. */ public static boolean isBound(String ip, int port) throws Exception { InetSocketAddress address = new InetSocketAddress(ip, port); return isBound(address); } /** */ private static boolean isBound(InetSocketAddress address) throws Exception { Socket socket = new Socket(); try { socket.bind(address); return false; } catch (IOException e) { return true; } finally { socket.close(); } } }