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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:14:53+00:00 2026-05-26T23:14:53+00:00

I need help thinking up a design where clients connect and communicate with all

  • 0

I need help thinking up a design where clients connect and communicate with all other clients. I’m thinking each client will simultaneously need a ServerSocket for listening for incoming connections from other clients and a Socket for initiating connections with other clients.

I’m testing on localhost, so if I use ports numbers to keep track of connections, I run into this scenario:

Socket A (OS assigned port: a) initiates connection with ServerSocket B (known port: 2222)
Both clients record that connection (a, 2222) is made
Socket B (OS assigned port: b) initiates connection with ServerSocket A (known port: 1111)
Both clients record that connection (b, 1111) is made

We should have 1 connection per pair of clients, so the above is a wasteful. THAT’S why I’m thinking setting about setting local ports myself: the scenario would change to connections (1111,2222) and (2222,1111), and since the second is the same, it’s not kept.

Does this sound reasonable?

  • 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-26T23:14:53+00:00Added an answer on May 26, 2026 at 11:14 pm

    Why do you require the client to set it’s local port? The way client, server sockets work is a bit different.

    Essentially when you have clients talking to each other, what you’re getting at is, every client has a incoming port (server socket) that it’ll listen on for other clients. When a client wishes to connect to a different client, it’ll always use this port to initiate the request. Upon getting the request, the client will simply accept the connection and pass it to the handling logic (be it a thread or NBIO type logic). In this scenario you don’t have to define the local port anywhere.

    I think one of the issues that you’re trying to solve is, what if a connection is already established between two clients? In that case, both parties know whom are the connected to and will not establish a new connection. In which case you’re looking at implementing your own protocol for a two-way duplex communication.

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

Sidebar

Related Questions

I need help to replace all \n (new line) caracters for in a String,
I need some help in thinking through the process to do batch update on
I actually need help on the thinking process and options, and not really on
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
Need help writing a script downloads data from google insight using c# this is
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help understanding some C++ operator overload statements. The class is declared like
I need help with this route map routes.MapRoute(Blog_Archive, Blog/Archive/{year}/{month}/{day}, new { controller = Blog,
I need help getting my head around the difference between my current OOP notion
I need help with the best practice to localize asp mvc apps, I saw

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.