@SuppressWarnings({"checkstyle:npathcomplexity"})
    @SuppressFBWarnings("RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED")
    private synchronized boolean bind0(TcpIpConnection connection, Address remoteEndpoint,
                                       Collection<Address> remoteAddressAliases, boolean reply) {
        final Address remoteAddress = new Address(connection.getRemoteSocketAddress());
        if (tcpIpEndpointManager.connectionsInProgress.contains(remoteAddress)) {
            // this is the connection initiator side --> register the connection under the address that was requested
            remoteEndpoint = remoteAddress;
        }
        if (remoteEndpoint == null) {
            if (remoteAddressAliases == null) {
                throw new IllegalStateException("Remote endpoint and remote address aliases cannot be both null");
            } else {
                // let it fail if no remoteEndpoint and no aliases are defined
                remoteEndpoint = remoteAddressAliases.iterator().next();
            }
        }
        connection.setEndPoint(remoteEndpoint);
        ioService.onSuccessfulConnection(remoteEndpoint);
        if (reply) {
            BindRequest bindRequest = new BindRequest(logger, ioService, connection, remoteEndpoint, false);
            bindRequest.send();
        }

        if (checkAlreadyConnected(connection, remoteEndpoint)) {
            return false;
        }

        if (logger.isLoggable(Level.FINEST)) {
            logger.finest("Registering connection " + connection + " to address " + remoteEndpoint);
        }
        boolean returnValue = tcpIpEndpointManager.registerConnection(remoteEndpoint, connection);

        if (remoteAddressAliases != null && returnValue) {
            for (Address remoteAddressAlias : remoteAddressAliases) {
                if (logger.isLoggable(Level.FINEST)) {
                    logger.finest("Registering connection " + connection + " to address alias " + remoteAddressAlias);
                }
                tcpIpEndpointManager.connectionsMap.putIfAbsent(remoteAddressAlias, connection);
            }
        }

        return returnValue;
    }
@ SuppressWarnings ( { "checkstyle:npathcomplexity" } ) @ SuppressFBWarnings ( "RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED" ) private synchronized boolean bind0 ( TcpIpConnection connection , Address remoteEndpoint , Collection < Address > remoteAddressAliases , boolean reply ) { final Address remoteAddress = new Address ( connection . getRemoteSocketAddress ( ) ) ; if ( tcpIpEndpointManager . connectionsInProgress . contains ( remoteAddress ) ) { remoteEndpoint = remoteAddress ; } if ( remoteEndpoint == null ) { if ( remoteAddressAliases == null ) { throw new IllegalStateException ( "Remote endpoint and remote address aliases cannot be both null" ) ; } else { remoteEndpoint = remoteAddressAliases . iterator ( ) . next ( ) ; } } connection . setEndPoint ( remoteEndpoint ) ; ioService . onSuccessfulConnection ( remoteEndpoint ) ; if ( reply ) { BindRequest bindRequest = new BindRequest ( logger , ioService , connection , remoteEndpoint , false ) ; bindRequest . send ( ) ; } if ( checkAlreadyConnected ( connection , remoteEndpoint ) ) { return false ; } if ( logger . isLoggable ( Level . FINEST ) ) { logger . finest ( "Registering connection " + connection + " to address " + remoteEndpoint ) ; } boolean returnValue = tcpIpEndpointManager . registerConnection ( remoteEndpoint , connection ) ; if ( remoteAddressAliases != null && returnValue ) { for ( Address remoteAddressAlias : remoteAddressAliases ) { if ( logger . isLoggable ( Level . FINEST ) ) { logger . finest ( "Registering connection " + connection + " to address alias " + remoteAddressAlias ) ; } tcpIpEndpointManager . connectionsMap . putIfAbsent ( remoteAddressAlias , connection ) ; } } return returnValue ; }
Performs the actual binding (sets the endpoint on the Connection, registers the connection)
without any spoofing or other validation checks.
When executed on the connection initiator side, the connection is registered on the remote address
with which it was registered in {@link TcpIpEndpointManager#connectionsInProgress},
ignoring the {@code remoteEndpoint} argument.

@param connection            the connection to bind
@param remoteEndpoint        the address of the remote endpoint
@param remoteAddressAliases  alias addresses as provided by the remote endpoint, under which the connection
will be registered. These are the public addresses configured on the remote.