FreeRTOS_closesocket()

[FreeRTOS Embedded IP Stack API]

FreeRTOS_sockets.h
BaseType_t FreeRTOS_closesocket( xSocket_t xSocket );
		

Close a socket.

The function is named FreeRTOS_closesocket() rather than simply FreeRTOS_close() to avoid potential name space collisions with functions in FreeRTOS+IO.

A socket cannot be used after it has been closed.

Parameters:

xSocket   The handle of the socket being closed. The socket must have already been created (see FreeRTOS_socket()), and cannot be used after it has been closed.

Returns:

0 is always returned.

Although FreeRTOS+UDP does not [currently] use the return value in a meaningful way, the return value is included in the function prototype to ensure consistency with the expected standard Berkeley sockets API, and to ensure compatibility with future versions of FreeRTOS+UDP.

Example usage:


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

void aFunction( void )
{
xSocket_t xSocket;

/* Create a socket. */
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );

if( xSocket != FREERTOS_INVALID_SOCKET )
{
/*
* The socket can now be used…
*/


/* Close the socket again. */
FreeRTOS_closesocket( xSocket );
}
}



Example use of the FreeRTOS_close() 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 MIT licensed IoT MQTT and IoT Task Pool libraries now available. Includes demo projects.

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

Careers

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
Renesas
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