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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:09:34+00:00 2026-06-07T16:09:34+00:00

I have a TCP server/client set up and they communicate the way I generally

  • 0

I have a TCP server/client set up and they communicate the way I generally want.

What I want to do now is add functionality that would allow the client to automatically reconnect to the server once a connection is lost. I’m having trouble finding complete information online on how to do this.

Details:
-I only have 1 server and so far it only hosts at most 1 connection.
-When either the client OR the server disconnects – both close (is it sensible to close both the server’s and client’s sockets like this?)

Ideally, I would like for the client to be able to reconnect to the same port on the server each time. I understand TIME_WAIT and why it is necessary. I don’t really want to use SO_REUSEADDR unless I don’t have another option. How is this generally handled? Should I open a new port on the Server side while it waits for the old socket to finish TIME_WAIT and basically alternate between the two ports (which means that the client would have to keep track of 2 possible ports)?

Thanks for your suggestions !

  • 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-07T16:09:37+00:00Added an answer on June 7, 2026 at 4:09 pm

    TIME_WAIT is state of TCP connection, not the port. Every TCP connection identifies by tuple (local-address, local-port, remote-address, remote-port). So if the client connect to server using new (dynamic) local port then new TCP connection is created and TIME_WAIT isn’t issue.

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

Sidebar

Related Questions

Right now I've got a simple TCP server/client. I have it set up so
I have a client/server program in TCP written in C, and I would like
I have a Client program by tcp connection that send data to a server.
I have a server application that receives some special TCP packet from a client
I have a Java client that connects to a C++ server using TCP Sockets
I have a server-client application [TCP sockets, .NET 4.0].. the application about : do
I have built a simple TCP server and need to compare client input with
I have a server that connects to multiple clients using TCP/IP connections, using C
I have a TCP server app that is written in C#. I accept TCP
I have a client that will send a lots of data to server from

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.