Skip to content

controllers: tcpip: use shutdown instead of close#4

Open
cfriedt wants to merge 1 commit intoanobli:masterfrom
cfriedt:shutdown-instead-of-close-for-tcpip
Open

controllers: tcpip: use shutdown instead of close#4
cfriedt wants to merge 1 commit intoanobli:masterfrom
cfriedt:shutdown-instead-of-close-for-tcpip

Conversation

@cfriedt
Copy link
Copy Markdown

@cfriedt cfriedt commented Dec 3, 2020

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.

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.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant