Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
How to reuse TCP listening socket immediately after it was connectedat least once?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Roy Smith, post: 3867499, member: 130667"] In theory, that is indeed the reason for the TIME_WAIT state. In practice, however, using SO_REUSEADDR is pretty safe, and common practice. You've got several things working in your favor. First, late-delivery of packets is pretty rare. Second, if some late packet were to arrive, the chances of them having the same local and remote port numbers as an existing connection is slim. And, finally, the TCP sequence number won't line up. One thing to be aware of is that SO_REUSEADDR isn't 100% portable. There are some systems (ISTR HP-UX) which use SO_REUSEPORT instead of SO_REUSEADDR. The original specifications weren't very clear, and some implementers read them in strange ways. Some of that old code continues in use today. I only mention this because if you try SO_REUSEADDR and it's not doing what you expect, it's worth trying SO_REUSEPORT (or both) to see what happens on your particular system. That may be a reasonable thing to do for production code, but when you're building and debugging a server, it's a real pain to not be able to restart it quickly whenever you want (or need) to. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
How to reuse TCP listening socket immediately after it was connectedat least once?
Top