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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:13:16+00:00 2026-06-05T09:13:16+00:00

I feel these might be basic topics, but I couldn’t find them succinctly answered

  • 0

I feel these might be basic topics, but I couldn’t find them succinctly answered elsewhere.

When building a TCP server, my understanding is that each connecting client has to be farmed off to its own port in order to maintain sensible connectivity (e.g. to know that this message is coming from this client).

How does one set this up? I assume that you’d have a List and a dedicated ‘entry point’ Socket that people connected to. The connecting Socket would find a free port, reply with the port number, and set up a new Socket listening on that port. Does this sound about right?

If this is the case, it seems to me that the entry Socket would need to block while listening for incoming connections. Is this blocking read done on a separate thread?

Additional side-question: I really just need some simple message-passing for a basic Java game I want to experiment with. Things like Netty seem like a sledgehammer for this particular walnut of an application. Am I best off writing something nice and lightweight using the Java standard library?

  • 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-05T09:13:18+00:00Added an answer on June 5, 2026 at 9:13 am

    The main socket is called a “mother socket” and you block on it waiting for new connections. When a new connection happens, you use the accept() method which creates a new socket just for the new client.

    You can manage these sockets by using a Selector. You configure the selector to listen to the mother socket and also any other sockets that you created. This way, you can have one thread listening for all incoming communication. If the new communication is on the mother socket, you accept the connection and generate a new socket and add it to the selector. If the new communication is on one of the other sockets, then you handle the message appropriately.

    I always write my own networking code. It’s a useful learning experience, but you also know exactly what these things are doing.

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

Sidebar

Related Questions

I've been thinking of implementing this system, but can't help but feel there's a
I feel like there's a simple solution to this, but I'm not really sure
I feel stupid for asking, but there must be a one liner that does
Feel free to close and/or redirect if this has been asked, but here's my
I feel like this is something I should already know, but I'm just not
This might be a pretty basic question, or peculiar to my set up (hopefully
I know this may not be exactly a coder question, but I feel it
This might be a way to simple question, but I seem to miss the
This is a very basic question. I feel kind of silly asking about it
This might seem like a silly question, but after asking some questions on stackoverflow

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.