Java Socket Address Get getAlreadyBoundServerSocket(String address, int port, boolean ssl, boolean useChannels)

Here you can find the source of getAlreadyBoundServerSocket(String address, int port, boolean ssl, boolean useChannels)

Description

get Already Bound Server Socket

License

Open Source License

Declaration

private static ServerSocket getAlreadyBoundServerSocket(String address, int port, boolean ssl,
            boolean useChannels) 

Method Source Code

//package com.java2s;
/*/*from ww  w . j  a  va2 s  .  c o m*/
 * ***** BEGIN LICENSE BLOCK *****
 * Zimbra Collaboration Suite Server
 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013, 2014, 2016 Synacor, Inc.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software Foundation,
 * version 2 of the License.
 *
 * This program 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 General Public License for more details.
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <https://www.gnu.org/licenses/>.
 * ***** END LICENSE BLOCK *****
 */

import java.net.ServerSocket;

import java.util.HashMap;

import java.util.Map;

public class Main {
    private static Map<String, ServerSocket> mBoundSockets = new HashMap<String, ServerSocket>();

    private static ServerSocket getAlreadyBoundServerSocket(String address, int port, boolean ssl,
            boolean useChannels) {
        //dumpMap();
        String key = makeKey(address, port, ssl, useChannels);
        ServerSocket serverSocket = mBoundSockets.get(key);
        //System.err.println("get table=" + mBoundSockets.hashCode() + " key=" + key + " sock=" + serverSocket);
        return serverSocket;
    }

    private static String makeKey(String address, int port, boolean ssl, boolean useChannels) {
        return "[ssl=" + ssl + ";addr=" + address + ";port=" + port + ";useChannels=" + useChannels + "]";
    }
}

Related

  1. getAddress(SocketAddress address)
  2. getAddress(SocketAddress address)
  3. getAddressFirst(InetSocketAddress inetSocketAddress)
  4. getAddressRepresentation(final SocketAddress address)
  5. getAddrString(final SocketAddress address)
  6. getBestAddress(InetSocketAddress addr)
  7. getCanonicalConnectionAddress(InetSocketAddress address)
  8. getClientPort(SocketAddress socketAddress)
  9. getConnectAddress(InetSocketAddress addr)