After reading a few web pages about the network, trying to understand basic network technologies (I had never worked on the network before), I made several classes that are designed to create a simple chat. The following classes will be placed below:
ChatServer: http://paste.strictfp.com/32591 ((Recently edited) Creating an 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 simply basically reads messages sent by clients)
ChatClient: http://paste.strictfp.com/32584 (Allows the client to write to the server)
ServerRunner: http://paste.strictfp.com/32585 (Basic server startup method)
ClientRunner: http://paste.strictfp.com/32586 (The main method for starting a client that connects to the server)
I know that the code above is not the best, given the fact that I did not add any checks to check if the socket / client was disconnected or something was interrupted. But then again, it was just a practice to help me try to understand the concept of networks.
So these 5 classes work together fine, but I have a question / concern that would be very helpful if he answered:
How to send a message from the server to the client?
The reason I ask is because I want to create a simple tic-tac-toe multiplayer game that will have a server and 2 clients (both representing players) and basically what I had in mind was that whenever clients click on the buttons, I send a message to the server. And then I will send a message to both clients to change both games. And I'm a little confused about how this works, due to my lack of network knowledge. I would appreciate it if you did not redirect me to another URL, if not very, very simple, because I prefer people to explain this to me in simple words. If someone can help me, he will be very grateful.