}
private Socket wrapSocket(Socket toWrap) {
CloseMonitoringSocket wrappedSocket = new CloseMonitoringSocket(toWrap, socketConnectListener, source);
SocketConnectedEvent connectedEvent = new SocketConnectedEvent(source, toWrap, wrappedSocket);
fireEvent(socketConnectListener, connectedEvent);
// Change the wrapped socket if one of the receivers of the SocketConnectedEvent changed it
Socket connectedEventSocket = connectedEvent.getSocket();
if (connectedEventSocket != wrappedSocket) {
wrappedSocket.setWrappedSocket(connectedEventSocket);
return connectedEventSocket;
}