Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linger time = 0 -> unconditional hard disconnect #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmcdonnell
Copy link

Provide a way for an application using the Socket API to hard close a TCP socket when it wants to abort, regardless of whether there's any pending or unacked data.

Example application code:

void hardDisconnect(int sock)
{
   struct linger linger =
   {
     .l_onoff  = 1,
     .l_linger = 0,
   };

   lwip_setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof linger);
   lwip_shutdown(sock, SHUT_RDWR);
   lwip_close(sock);
}

References supporting this approach are included in the commit message.

Background discussion on bug #62231.

…rdless of whether there's any pending or unacked data

References:
 - Wright & Stevens, "TCP/IP Illustrated, Volume 2"
   - 30.4. tcp_disconnect Function
     - Figure 30.12. tcp_disconnect function: initiate TCP disconnect.
	 - "Hard disconnect" section
 - UNIX Network Programming / Volume 1, Third Edition: The Sockets Networking API
   (aka "UNP")
   - 7.5 Generic Socket Options
     - "SO_LINGER Socket Option" section
@bmcdonnell
Copy link
Author

This worked well for me in bench testing with my own application (an embedded http client). I did not run the lwIP unit tests with it.

I think this patch (w/ appropriate application code like my example) may resolve the original issue in bug #62231, but the original poster reports he is unable to test further.

@bmcdonnell bmcdonnell marked this pull request as ready for review July 3, 2024 11:03
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