This method waits until a client attempts to connect to the server, and it returns an instance of the Connection class.This Connection instance (skt) is now the route through which we can communicate with the client.I left the server code as is, but tried to improve on the client code. As it was, it was full of both GUI code and networking code. In order to start a network session, a server and a client are required , and a server is set up to listen at a given port.The server waits and does nothing until a client attempts to connect to that port.Simple Chat package nl.rickhurkens.chatting; import Socket; public class Chat Controller implements Send Listener package nl.rickhurkens.chatting; import javax.swing.
The following is a simple example that illustrates the different portions of a server/client pair.
I thought this was not a good idea and tried to split it up nicely.
I tried to use an observer pattern to let the networking class know the user sent a new message.
It attempts to contact the server at localhost through port 1234 - the same port where the server is listening.
Once the Connection is at hand, it works exactly the same as the one obtained through the Server Connection class in
In the book Head First Java there was this coding example that created a very simple chat client and server.