Jump to main content

##

# TCPIP_UDP_ClientOpen Function

## C

    UDP_SOCKET TCPIP_UDP_ClientOpen(IP_ADDRESS_TYPE addType, UDP_PORT remotePort, IP_MULTI_ADDRESS* remoteAddress);

## Returns

- INVALID_SOCKET - No sockets of the specified type were available to be opened.
- A UDP_SOCKET handle - Save this handle and use it when calling all other UDP APIs.

## Description

Provides a unified method for opening UDP client sockets.

## Remarks

Sockets and user threads protection For efficiency reasons, there is NO PROTECTION for each individual API call except to Open and Close sockets! What it means is that:

- the user application should close all its sockets before issuing a stack/if down command The stack manager takes care of the internally used sockets

- A socket can NOT be used concurrently from multiple threads! It's ok to pass a socket from one thread to another as long as there's is no access from more than one thread at a time

## Preconditions

UDP is initialized.

## Parameters

Parameters | Description
--- | ---
IP_ADDRESS_TYPE | addType The type of address being used. Example: IP_ADDRESS_TYPE_IPV4 or IP_ADDRESS_TYPE_IPV6. It can also be IP_ADDRESS_TYPE_ANY if the type of the socket will be specified later (using TCPIP_UDP_Bind, TCPIP_UDP_RemoteBind).
UDP_PORT | remotePort The remote UDP port to which a connection should be made. The local port for client sockets will be automatically picked by the UDP module.
IP_MULTI_ADDRESS* | remoteAddress The remote address to connect to. Not used if addType == IP_ADDRESS_TYPE_ANY. Can be NULL if later set by a call to TCPIP_UDP_RemoteBind.