public boolean checkPort(int _port){
        ServerSocket socket = null;
    try {
        socket = new ServerSocket(_port);
        socket.close();
        return true;
    } catch (IOException e) {
        return false;
    } finally {
        if (socket != null)
            try {
                socket.close();
            } catch (IOException e) {return false;}
}
    }