Jump to main content

##

# TCPIP_TCP_RemoteBind Function

## C

    bool TCPIP_TCP_RemoteBind(
        TCP_SOCKET hTCP,
        IP_ADDRESS_TYPE addType,
        TCP_PORT remotePort,
        IP_MULTI_ADDRESS* remoteAddress
    );

## Description

This function is meant for unconnected server and client sockets. Sockets don't need specific remote binding, they should accept connections on any incoming interface. Thus the binding is done automatically by the stack. However, specific remote binding can be requested using these functions. For a server socket it can be used to restrict accepting connections from a specific remote host. For a client socket it will just change the default binding done when the socket was opened.

## Preconditions

TCP socket should have been opened with TCPIP_TCP_ServerOpen()/TCPIP_TCP_ClientOpen(). hTCP - valid socket.

## Parameters

Parameters | Description
--- | ---
hTCP | Socket to bind.
addType | The type of address being used. Example: IP_ADDRESS_TYPE_IPV4/IP_ADDRESS_TYPE_IPV6.
remotePort | Remote port to use Could be 0 if the remote port does not need to be changed.
remoteAddress | The remote address to bind to. Could be NULL if the remote address does not need to be changed.

## Returns

- True - Indicates success.
- False - Indicates failure.

## Remarks

The socket remote port is changed only if a non-zero remotePort value is passed.

The socket remote host address is changed only if a non-zero remoteAddress value is passed.

The call will fail if the socket is already connected (both server and client sockets).