Download FreeRTOS
 

Quality RTOS & Embedded Software

LIBRARIES
WHAT'S NEW
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.

Shutting Down and Closing a TCP Socket
Part of the FreeRTOS-Plus-TCP Networking Tutorial

A TCP socket that is not connected can be closed using the FreeRTOS_closesocket() API function.

A TCP socket that is connected should not be closed until the connection has been shut down. To gracefully shut down a socket first call FreeRTOS_shutdown(), then wait for read attempts on the socket to return -pdFREERTOS_ERRNO_EINVAL, indicating that the socket is no longer connected.

The source code examples on both the Sending TCP Data and the Receiving TCP Data pages demonstrate a connected socket being shut down then closed.


<< Back to the RTOS TCP networking tutorial index

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.