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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:10:04+00:00 2026-06-10T07:10:04+00:00

After reading several webpages about networking, in attempt to trying to understand basic networking,

  • 0

After reading several webpages about networking, in attempt to trying to understand basic networking, (I’ve never done networking before) I’ve made a few classes that is designed to make somewhat of a simple chat room. The following classes will be posted below:

ChatServer: http://paste.strictfp.com/32591 ((Edited recently)Creating the actual server that waits for people to connect to it, in this case, through port 9045)

ChatSession: http://paste.strictfp.com/32583 (When a client is found, from the server code above, it creates a new session, which just basically reads the messages that are sent by the clients)

ChatClient: http://paste.strictfp.com/32584 (Allows a client to write to the server)

ServerRunner: http://paste.strictfp.com/32585 (Main method for running the server)

ClientRunner: http://paste.strictfp.com/32586 (Main method for running a client, which connects to the server)

I know the code above isn’t the best, considering the fact that I didn’t add any checks to see if the socket/client got disconnected, or something got interrupted. But then again, this was just a practice in order to help me try and grasp the concept of networking.

So these 5 classes together work fine, but I have a question/concern that would be very much appreciated if answered:

How do I send a message from the server to a client?

The reason why I’m asking is this because I want to make a simple multiplayer tic-tac-toe game, in which there will be a server, and 2 clients (both representing players) and basically what I had in mind was that whenever the clients click on buttons, I’d send a message to the server. And then I would send the message back to both clients in order to modify both of their games. And I’m just a little confused about how it works, due to my lack of networking knowledge. I’d appreciate if you didn’t redirect me to another URL, unless very very very simple, because I prefer if people explain it to me in simplest terms. If someone can help me, it’d be very much appreciated.

  • 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-10T07:10:06+00:00Added an answer on June 10, 2026 at 7:10 am

    There are two meanings for the word “server” which can be confusing:

    1. Server is what is not at the customer (i.e. it the central hub to which every customer/user connects to)
    2. Server is the one receiving requests. Servers never initiate conversations, they only always respond to incoming messages.

    So what you try to do is to turn your server into a client (and the ChatClient would become a server).

    This explains why this seemingly simple task is so hard: Servers aren’t meant to talk to clients out of the blue. Real world example: A clerk from your bank suddenly shows up on your doorstep and tries to sell you something at your home. Odd, isn’t it?

    Solutions:

    1. You can have the client send a message to the server every few minutes. The message would be “Is there something new?”. This is called “polling”.
    2. You can have the client send a message and let it wait for the answer. There is no need for the server to reply to messages right away. There will be timeouts, though, that you need to handle. But the client could send one “Is there something new?” and then wait until it gets a reply. If you move this into a thread, the client could do something else while it waits for an answer. This is polling but it’s passive.
    3. You can use a bi-directional protocol like WebSocket.
    4. You can turn your client into a real server: Open a server socket, let the central hub know the port number and let it connect there to update your client. While this works, it needs two connections and they are a bit expensive. This works well for small amounts of clients but as the number grows, it eventually becomes a problem.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading several articles of a hierarchical data tables, I've made my way into
After reading several posts on this matter, I thought I was all clear about
After reading several questions about .gitignore I have found no one that could answer
After reading several questions/answers about unit testing Entity Framework, I have decided to forgo
After reading several questions regarding problems with compilation (particularly C++) and noticing that in
After reading MSDN-XAML Namespaces and MSDN-Understanding XAML Namespaces , I still do not understand
after a lot of googling and reading several solutions on how to manage mixed
I've been reading several threads and questions about this issue but I didn't find
I notice this has caused confusion for several people, but after reading a couple
After reading lots of blogs, forum entries and several Apple docs, I still don't

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.