Jump to main content

##

# TCPIP_UDP_ServerOpen Function

## C

    UDP_SOCKET TCPIP_UDP_ServerOpen(IP_ADDRESS_TYPE addType, UDP_PORT localPort, IP_MULTI_ADDRESS* localAddress);

## Returns

- INVALID_SOCKET - No sockets of the specified type were available to be opened or parameter error.

- A UDP_SOCKET handle - Save this handle and use it when calling all other UDP APIs.

## Description

Provides a unified method for opening UDP server 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.

## Example

IP_ADDRESS_TYPE_IPV4 or IP_ADDRESS_TYPE_IPV6. It can be IP_ADDRESS_TYPE_ANY and the server socket will accept any incoming type of connection. UDP_PORT localPort - UDP port on which to listen for connections IP_MULTI_ADDRESS* localAddress - Pointer to a local IP address to use. This needs to be the valid IP address of a local interface the server is to listen on or NULL if any incoming interface will do.

## Parameters

Parameters | Description
--- | ---
IP_ADDRESS_TYPE addType | The type of address being used.