Forum | Documentation | Website | Blog

Skip to content

controllers: tcpip: use shutdown instead of close

Created by: cfriedt

When close(fd) is used on the a TCP/IP socket in Linux, it puts the socket into a FIN_WAIT1 state and the TCP/IP connection is not completely severed until the application terminates. On the server side, this has the effect of keeping sockets open for an unnecessarily long period of time. If the server is a memory-contstrained device such as a microcontroller, that can have very negative effects.

For that reason, it is preferred to use shutdown(fd, SHUT_RDWR) instead.

Merge request reports