Here you can find the source of removeSocket(String host, int port)
public static void removeSocket(String host, int port)
//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(); } } }