Jump to main content

##

# TCPIP_UDP_RemoteBind Function

## C

    bool TCPIP_UDP_RemoteBind(UDP_SOCKET hUDP, IP_ADDRESS_TYPE addType, UDP_PORT remotePort, IP_MULTI_ADDRESS* remoteAddress);

## Returns

- true - Indicates success
- false - Indicates failure

## Description

Sockets don't need specific remote binding, they should accept connections on any incoming interface. Therefore, the binding is done automatically by the stack. However, specific remote binding can be requested using this function. 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.

## Remarks

If address type IP_ADDRESS_TYPE_ANY is used, the remoteAddress parameter won't be used and the socket won't change the remote destination address. However, for the call to succeed, socket must have been created with IP_ADDRESS_TYPE_ANY type and must not be currently bound to a IP_ADDRESS_TYPE_IPV4/IP_ADDRESS_TYPE_IPV6 type. If address type IP_ADDRESS_TYPE_IPV4/IP_ADDRESS_TYPE_IPV6 is used, then the socket type will be changed accordingly, and the remoteAddress will be used, if provided. The socket will be bound to this type of address. For the call to succeed the socket must currently have the type IP_ADDRESS_TYPE_ANY or to match the addType parameter. If the remoteAddress != 0 and addType != IP_ADDRESS_TYPE_ANY, the call will enforce UDP_OPTION_STRICT_ADDRESS on the socket. The remote port is always changed, even if remotePort == 0. It will enforce UDP_OPTION_STRICT_PORT on the socket. In order to change dynamically the type of address, the socket must have been created with a IP_ADDRESS_TYPE_ANY type and not currently bound to a different address type. TCPIP_UDP_Disconnect could be issued to remove a previous IP type binding. If the socket is a server socket and is bound to a remote port, the TCPIP_UDP_Disconnect won't remove the port binding.

## Preconditions

UDP socket should have been opened with TCPIP_UDP_ServerOpen/TCPIP_UDP_ClientOpen. hUDP - valid socket

## Parameters

Parameters | Description
--- | ---
hUDP | The socket to bind.
addType | The type of address being used. Valid values are IP_ADDRESS_TYPE_ANY/IP_ADDRESS_TYPE_IPV4/IP_ADDRESS_TYPE_IPV6 .
remotePort | The remote port to bind to.
remoteAddress | Remote address to use.