Here you can find the source of isOpen(final int port)
Parameter | Description |
---|---|
port | The port to check |
public static boolean isOpen(final int port)
//package com.java2s; import java.io.IOException; import java.net.Socket; public class Main { /**/* www . java2 s . c o m*/ * Port is open. * @param port The port to check * @return TRUE if it's open */ public static boolean isOpen(final int port) { boolean open; try { new Socket((String) null, port); open = true; } catch (final IOException ex) { open = false; } return open; } }