[FreeRTOS Embedded IP Stack API]

uint32_t FreeRTOS_inet_addr( const uint8_t * pucIPAddress );

FreeRTOS_inet_addr() is a function that converts an IP address expressed in decimal dot notation (for example “”) into a 32-bit IP address in network byte order.

FreeRTOS_inet_addr_quick() is a macro that converts an IP address expressed as four separate numeric octets (for example 192, 168, 0, 100) into a an IP address expressed as a 32-bit number in network byte order

FreeRTOS_inet_addr_quick() is the preferred method because of its smaller size and faster execution. FreeRTOS_inet_addr() is provided because it conforms to the expected Berkeley sockets function prototype.

ipconfigINCLUDE_FULL_INET_ADDR must be set to 1 in FreeRTOSIPConfig.h for FreeRTOS_inet_addr() to be available. FreeRTOS_inet_addr_quick() is always available.


pucIPAddress   A pointer to a string that contains the IP address being converted in decimal dot format.


If the format of the string pointed to by the pucIPAddress parameter is valid then the same IP address expressed as a 32-bit number in network byte order is returned. In all other cases 0 is returned.

Example usage:

This example sends a string to port 5000 of IP address, using FreeRTOS_inet_addr() to convert the IP address from a string to the necessary 32-bit format. The socket is passed in as the function parameter, and is assumed to have already been created using a call to FreeRTOS_socket(). If ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is not set to 1 in FreeRTOSIPConfig.h, then the socket is also assumed to have been bound to a port number using FreeRTOS_bind().

/* FreeRTOS+UDP sockets include */
#include “FreeRTOS_sockets.h”

void aFunction( xSocket_t xSocket )
struct freertos_sockaddr xDestinationAddress;
const int8_t *pcMessageToSend = “String being sent”;

/* Generate the destination address. */
xDestinationAddress.sin_addr = FreeRTOS_inet_addr( “” );
xDestinationAddress.sin_port = FreeRTOS_htons( 5000 );

/* Send the message. */
iReturned = FreeRTOS_sendto(
/* The socket being send to. */
/* The data being sent. */
/* The length of the data being sent. */
strlen( pcMessageToSend ),
/* ulFlags with the FREERTOS_ZERO_COPY bit clear. */
/* Where the data is being sent. */
/* Not used but should be set as shown. */
sizeof( xDestinationAddress )

Example use of the FreeRTOS_inet_addr_quick() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo & Nuvoton Cortex-M23 demo & STM32H745 dual core (AMP) demo.

New Updates to MIT licensed IoT MQTT and POSIX libraries are now available. New library IoT HTTPS is available.  Includes demo projects.

View a recording of the “OTA Update Security and Reliability” webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners
ARM Connected RTOS partner for all ARM microcontroller cores
Espressif ESP32
IAR Partner
Microchip Premier RTOS Partner
STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0
Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers
OpenRTOS and SafeRTOS
Xilinx Microblaze and Zynq partner