nRF5 SDK v16.0.0
Functions

Port database for sockets. More...

Functions

uint32_t portdb_init (uint32_t max_len)
 Function for initializing the port database. More...
 
void portdb_deinit (void)
 Function for deinitializing the portdb. More...
 
void portdb_reset (void)
 Function to reset all ports without freeing any memories.
 
uint32_t portdb_alloc (uint16_t *p_port)
 Function for allocating a port. More...
 
uint32_t portdb_register (uint16_t port)
 Function for registering a port. More...
 
void portdb_free (uint16_t port)
 Function for freeing a port. More...
 

Detailed Description

Port database for sockets.

The port database provides a functionality for registering, allocating, and freeing ports.

Function Documentation

uint32_t portdb_alloc ( uint16_t *  p_port)

Function for allocating a port.

Looks for an available port in the database and allocates it to the caller.

Parameters
[out]p_portPointer to a variable where the allocated port number should be stored.
Return values
NRF_SUCCESSIf a free port was located and successfully allocated.
SOCKET_NO_AVAILABLE_PORTSIf no available ports were found.
void portdb_deinit ( void  )

Function for deinitializing the portdb.

This will free all memory allocated by this portdb.

void portdb_free ( uint16_t  port)

Function for freeing a port.

Mark a given port as free and make it available for others to register or allocate.

Parameters
[in]portThe port to mark as free.
uint32_t portdb_init ( uint32_t  max_len)

Function for initializing the port database.

This must be called before allocating and freeing ports.

Parameters
max_lenThe max length of the portdb.
Return values
NRF_SUCCESSIf successfully initialized.
uint32_t portdb_register ( uint16_t  port)

Function for registering a port.

Marks a given port in the database as being in use.

Parameters
[in]portThe port to mark as in use.
Return values
NRF_SUCCESSIf port was successfully marked as in use.
SOCKET_NO_AVAILABLE_PORTSIf there was no slot in which to register the port.
SOCKET_PORT_IN_USEIf the port has already been registered or allocated.

Documentation feedback | Developer Zone | Subscribe | Updated