Java Socket Port removeSocket(String host, int port)

Here you can find the source of removeSocket(String host, int port)

Description

remove Socket

License

Open Source License

Declaration

public static void removeSocket(String host, int port) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.net.Socket;
import java.util.HashMap;

public class Main {
    private static HashMap<String, Socket> sockets = new HashMap<String, Socket>();

    public static void removeSocket(String host, int port) {
        try {/* ww  w .j a v  a  2 s.c  o m*/

            Socket socket = sockets.get(host + ":" + port);
            if (socket != null) {
                socket.close();
                sockets.remove(host + ":" + port);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. getPort(ServerSocket server)
  2. getRandomPortServerSocket()
  3. getServerSocket(int i_Port)
  4. isValidSocket(String host, int port)
  5. releasePort(ServerSocket ss)
  6. waitForSocket(int port)