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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:01:54+00:00 2026-05-14T01:01:54+00:00

I have a defined number of servers that can locally process data in their

  • 0

I have a defined number of servers that can locally process data in their own way. But after some time I want to synchronize some states that are common on each server. My idea was that establish a TCP connection from each server to the other servers like a mesh network.

My problem is that in what order do I make the connections since there is no “master” server here, so that each server is responsible for creating there own connections to each server.

My idea was that make each server connect and if the server that is getting connected already has a connection to the connecting server, then just drop the connection.

But how do I handle the fact that 2 servers is trying to connect at the same time? Because then I get 2 TCP connections instead of 1.

Any ideas?

  • 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-14T01:01:55+00:00Added an answer on May 14, 2026 at 1:01 am

    You will need to have a handshake protocol when you’re connection to a server so you can verify whether it’s ok to start sending/receiving data, otherwise you might end up with one of the endpoint connecting and start sending data immediately only to have the other end drop the connection.

    For ensuring only one connection is up to a server,you just need something like this pseudocode:

    remote_server = accept_connection()
    lock mutex;
    if(already_connected(remote_server)) {
      drop_connection(remote_server)
    }
    unlock mutex;
    

    If your server isn’t multithreaded you don’t need any locks to guard you when you check whether you’re already connected – as there won’t be any “at the same time” issues.

    You will also need to have a retry mechanism to connect to a server based on a small random grace period in the event the remote server closed the connection you just set up.

    If the connection got closed, you wait a little while, check if you’re already connected (maybe the other end set up a connection to you in the mean time) and try to connect again. This is to avoid the situation where both ends set up the connection at the same time but the other end closes it because of the above logic.

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

Sidebar

Related Questions

I have defined CSS in MasterPage so that all pages can use the same
I have defined small MXML component which calls web service which returns random number
I have a number of aliases defined in my .bashrc . E.g: alias ls='ls
I have a table that stores data from the county appraisal district. I want
Does anyone have any suggestions on how I can take a DataSet that I
I have a PHP script that finds out the number of users on each
I have a number laptops that run our application while connected to each other
I have code that has a Dictionary defined as: Dictionary<int, StringBuilder> invoiceDict = new
I have a project that requires user-defined attributes for a particular object at runtime
I have a search form that offers a number of different search options, such

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.