public void discriminateConnection(Socket localSocket)
		throws IOException, ShutdownException {

		boolean closeSocket = true;

		try {
			final Connector.ConnectDetails connectDetails =
				Connector.read(localSocket.getInputStream());

			final SocketWrapper socketWrapper =
				new IdleAwareSocketWrapper(localSocket, m_timeAuthority);
			socketWrapper.setAddress(connectDetails.getAddress());

			// Possible minor race if the socket is closed between here...
			final ResourcePool.Closeable closeable =
				getSocketSet(connectDetails.getConnectionType()).add(socketWrapper);

			// .. and the time a listener is registered. Will pick up such a zombie
			// the next time we try to use the resource.
			socketWrapper.addClosedListener(new SocketWrapper.ClosedListener() {
				public void socketClosed() {
					closeable.close();
				}
			});

			// We did good.
			closeSocket = false;
		}
		catch (CommunicationException e) {
			try {
				m_exceptionQueue.put(e);
			}
			catch (InterruptedException ie) {
				throw new UncheckedInterruptedException(ie);
			}
		}
		finally {
			if (closeSocket) {
				try {
					localSocket.close();
				}
				catch (IOException ioException) {
					UncheckedInterruptedException.ioException(ioException);
					// Ignore.
				}
			}
		}
	}
Get the listener list for a particular connection type.
ngrinder-core/src/main/java/net/grinder/communication/Acceptor.java