Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:22:53+00:00 2026-06-11T17:22:53+00:00

All discussion I’ve seen on SO_REUSEADDR assumes that it’s the same program creating and

  • 0

All discussion I’ve seen on SO_REUSEADDR assumes that it’s the same program creating and binding to a TCP socket on a known port.

I have two different programs using the same port, and I’m curious about how the mechanism works — in order for program 2 to allocate a port program 1 has just closed, do they both have to specify SO_REUSEADDR after they create the socket?

Or is it enough for one of them? If so, the one taking the socket first or the one trying to open it afterwards, when it’s lingering in TIME_WAIT state?

Here’s a small example in Python to hopefully make the case clearer;

# one.py
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("", 5050)) # Assuming 5050 is available
sys.exit(1)        # Assuming s enters TIME_WAIT

# two.py
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("", 5050))
s.listen()

Think of one.py and two.py as two separate codebases.

Does both one.py and two.py need to set the SO_REUSEADDR socket option in order for two.py to tolerate a lingering TIME_WAIT socket from one.py?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:22:55+00:00Added an answer on June 11, 2026 at 5:22 pm

    To answer your question. I believe that on Linux you have to specify SO_REUSEADDR ONLY in the program that wants to reuse the port. Very simple. On Microsoft Windows however, this is a different story. Microsoft has a page on MSDN that covers SO_REUSEADDR and related features.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was recently reading this discussion at SO where somebody commented that not all
Inspired by the discussion in this question . We have all been taught that
I was wondering how can I programmatically copy all the discussion items from one
All I want to do is return the index of the i that is
I am trying to get a discussion with all it's replies from the sharepoint
I see from this discussion , and the Nick Hodges blog , that the
We're all aware of the horrors of the GIL , and I've seen a
Select all the CSS hack(s) that IE6 can understand for class red <p class=red>text</p>
I am having a discussion with someone about the following table that is used
Working in a team, all using IntelliJ, there's some discussion about checking-in or not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.