How nguyenmanhcuong-huster/chat-application-using-sockets works
Project type and purpose
• This is a simple Java‐based chat application built with two separate modules:
• ClientApp – a Swing GUI that connects to a chat server over TCP sockets
• ServerApp – a headless server that accepts socket connections and broadcasts messages
• The README (“Chat‐application‐using‐sockets”) confirms it’s a socket‐based real-time messaging tool.
File structure
• Top‐level directories:
• ClientApp/ – contains NetBeans project for the client GUI
• ServerApp/ – contains NetBeans project for the server
• Under each:
• src/ – Java source (e.g. ClientApp.java, ChatServer.java, ClientHandler.java)
• nbproject/ & build.xml – NetBeans and Ant build scripts
• dist/ – compiled JARs and libs (AbsoluteLayout.jar for GUI layout)
• No persistence layer, no external services—pure client/server over TCP.
README for additional insights
• Client launches a Swing WindowClient, uses ClientListener to read from socket
• Server launches ChatServer on a port, spins off ClientHandler per connection
a. Main components:
– ClientApp GUI
– ClientListener (message‐send/receive logic)
– TCP Socket (network link)
– ChatServer (listener/thread acceptor)
– ClientHandler threads (per‐client message broker)
b. Relationships and interactions:
– User types text in GUI → ClientListener sends via Socket → ChatServer.accept()
– ChatServer hands socket to new ClientHandler → broadcasts to all other handlers → data travels back over TCP → ClientListener updates GUI
c. Architectural patterns/design principles:
– 1:N server threading model (listener + per‐client handler threads)
– MVC-style separation in ClientApp (WindowClient as View/Controller, ClientListener as Model/network layer)
– Single responsibility (ChatServer only accepts connections; ClientHandler only routes messages)
d. Key technologies/frameworks:
– Java SE 8+ (java.net.Socket, java.net.ServerSocket)
– Swing for GUI (WindowClient.form, AbsoluteLayout.jar)
– Ant/NetBeans build scripts