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 7673863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:36:37+00:00 2026-05-31T16:36:37+00:00

Following is my environment: Linux, Ubuntu C++/gdb Eclipse I am implementing a TCP socket

  • 0

Following is my environment:

  1. Linux, Ubuntu
  2. C++/gdb
  3. Eclipse

I am implementing a TCP socket server application.
While developing/debugging, the application might terminate after a connection was accepted, and, before the open sockets were gracefully shutdown & closed.
On such a scenario, the next execution of the application will fail binding to the listening port, only after waiting a minute or so binding will succeed again.

My assumption is that the Linux kernel has some cleanup mechanism to ~collect~ all sockets that were not gracefully shutdown, explaining why I have to wait ~1 min before the port is bind-able again.

Having that said, is there any way of avoiding this 1 min wait? Is there any way of forcing the OS to collect all sockets that were not gracefully shutdown?

Any help will be appreciated.

Nadav at Sophin

  • 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-05-31T16:36:38+00:00Added an answer on May 31, 2026 at 4:36 pm

    Sure there is, just set the SO_REUSEADDR SOL_SOCKET level option on the socket.

    int yes = 1;
    if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes))
        perror("setsockopt");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following this blog in setting Xvfb in my ubuntu environment: http://corpocrat.com/2008/08/19/how-to-install-xvfb-x11-server-in-linux-server/ So
I have tried following how-set-up-your-own-private-git-server-linux and private-remote-git-repositories-ubuntu-linode but I am still having problems. My
How would you approach benchmarking the following XSL:T process. Testing environment: a Linux server
imagine the following environment: an XBAP application running in partial trust mode (default behaviour;
we have the following environment: a Windows 2008 Server with Apache 2.2.14 and SVN
Currently I'm checking it in the following way: if (Environment.UserInteractive) Application.Run(new ServiceControllerForm(service)); else ServiceBase.Run(windowsService);
I've got the following build environment : Ubuntu Java 1.6.0_24 Apache ant 1.8.2 Jenkins
In an embedded linux environment (customized 2.4.25 on PowerPC) I get the following kernel
Possible Duplicate: How to read Linux environment variables in c++ How can the following
I am new to Linux,I need help on the following.. My application has been

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.