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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:52:55+00:00 2026-05-11T12:52:55+00:00

I am trying to make a simple game that goes across a TCP network.

  • 0

I am trying to make a simple game that goes across a TCP network.

The server does something like this to check for connections, in Server.java:

try {     server = new ServerSocket(port);     System.out.println('Server started on port ' + port);      while (true)     {         socket = server.accept();         System.out.println('A new player has joined the server.');         new Server(socket).start();     } } 

And to make a new client, in Player.java:

socket = new Socket(hostname, port); 

Now, this works fine and all, but I need the server to add the instance of the Player to an array list and be able to send all of them certain data. They both have main methods, so one computer can just run the server and have 4 other computers connect to it by running Player.java. If all Player does is create a new socket, how is the Server supposed to interact with each Player?

  • 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. 2026-05-11T12:52:56+00:00Added an answer on May 11, 2026 at 12:52 pm

    I’m not sure I understand the question.

    The call to accept will produce a different return value for each connecting client (typically representing the client address and port), so you need to store each of them. You can then interact via the sockets, Sun has a pretty good example in its tutorial:

    That being said, save yourself a lot of headache and think over the performance you expect from the game. You can save yourself a lot of trouble and easily add reliability and scalability if you use JMS and ActiveMQ for your communications rather than mess around with sockets yourself.

    Spend your time writing the game, not doing low-level socket programming, unless you’re trying to learn.

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

Sidebar

Related Questions

For quite awhile I have been trying to make a simple game in Java
I have just started trying to make a simple game with XNA 3.1 to
I've been trying to make a little simple game just to test my logics,
So I'm working on a simple iPhone game and am trying to make a
I'm trying to make some types in Django that map to standard Django types.
I've got basically a 2d game on the iPhone and I'm trying to set
I'm trying to implement some sort of 'just-for-me' game engine and the problem's plot
Trying to decide on a library for creating a window and capturing user input
There are plenty of great answers to questions about making a standalone executable, but

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.