[ ]
 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS Labs FreeRTOS+TCP FreeRTOS+FAT Contact / Enquiries

FreeRTOS+TCP is still in the lab
FreeRTOS+TCP is already used in commercial products and we encourage you to try it yourself. Be aware however that we are still refining its design, and the source code and documentation do not yet meet Real Time Engineers Ltd's strict quality standards.
Please use the forum for support, feedback and ideas, or contact us directly if you have a specific business interest.


[FreeRTOS+TCP API Reference]

uint32_t FreeRTOS_inet_addr_quick( uint8_t ucOctet1, uint8_t ucOctet2,
                                   uint8_t ucOctet3, uint8_t ucOctet4 );

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() 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 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.


ucOctet1   The first octet of the four octet IP address.

ucOctet2   The second octet of the four octet IP address.

ucOctet3   The third octet of the four octet IP address.

ucOctet4   The forth octet of the four octet IP address.


The IP address represented by the four parameters expressed as a single 32-bit number in network byte order.

Example usage:

This example sends a string to port 5000 of IP address, using FreeRTOS_inet_addr_quick() to convert the IP address from individual octets to a string in 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+TCP sockets include. */
#define "FreeRTOS_sockets.h"

void aFunction( Socket_t xSocket )
struct freertos_sockaddr xDestinationAddress;
const int8_t *pcMessageToSend = "String being sent";

    /* Generate the destination address. */
    xDestinationAddress.sin_addr = FreeRTOS_inet_addr_quick( 192, 168, 0, 100 );
    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

[ Back to the top ]    [ About FreeRTOS ]    [ FreeRTOS Labs Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.