public synchronized void remove(SocketBox sb) {

        int status = ((ManagedSocketBox) sb).getStatus();

        if (!allSockets.containsKey(sb)) {
            throw new IllegalArgumentException("This socket does not seem to exist in the socket pool.");
        }

        allSockets.remove(sb);

        if (status == ManagedSocketBox.FREE) {
            if (!freeSockets.containsKey(sb)) {
                throw new IllegalArgumentException("This socket is marked free, but does not exist in the pool of free sockets.");
            }
            freeSockets.remove(sb);

        } else {
            if (!busySockets.containsKey(sb)) {
                throw new IllegalArgumentException("This socket is marked busy, but does not exist in the pool of busy sockets.");
            }
            busySockets.remove(sb);
        }
    }
public synchronized void remove ( SocketBox sb ) { int status = ( ( ManagedSocketBox ) sb ) . getStatus ( ) ; if ( ! allSockets . containsKey ( sb ) ) { throw new IllegalArgumentException ( "This socket does not seem to exist in the socket pool." ) ; } allSockets . remove ( sb ) ; if ( status == ManagedSocketBox . FREE ) { if ( ! freeSockets . containsKey ( sb ) ) { throw new IllegalArgumentException ( "This socket is marked free, but does not exist in the pool of free sockets." ) ; } freeSockets . remove ( sb ) ; } else { if ( ! busySockets . containsKey ( sb ) ) { throw new IllegalArgumentException ( "This socket is marked busy, but does not exist in the pool of busy sockets." ) ; } busySockets . remove ( sb ) ; } }
remove socketBox from the pool, remove all references to it