<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adnane Bakkou</title>
    <description>The latest articles on DEV Community by Adnane Bakkou (@adbakkou).</description>
    <link>https://dev.to/adbakkou</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4253925%2Fdf6b8504-600c-42b4-8aeb-b359c1ea3334.png</url>
      <title>DEV Community: Adnane Bakkou</title>
      <link>https://dev.to/adbakkou</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adbakkou"/>
    <language>en</language>
    <item>
      <title>Building a Multi-Client Chat App with Java 21, JavaFX, and Virtual Threads</title>
      <dc:creator>Adnane Bakkou</dc:creator>
      <pubDate>Thu, 19 Nov 2026 14:26:36 +0000</pubDate>
      <link>https://dev.to/adbakkou/building-a-multi-client-chat-app-with-java-21-javafx-and-virtual-threads-2k7a</link>
      <guid>https://dev.to/adbakkou/building-a-multi-client-chat-app-with-java-21-javafx-and-virtual-threads-2k7a</guid>
      <description>&lt;p&gt;I built a multi-client desktop chat application as a university Java networking project. The goal was to connect several clients to one TCP server, exchange messages, and make the connection lifecycle visible through JavaFX interfaces.&lt;/p&gt;

&lt;p&gt;The result is two independent Maven applications: &lt;strong&gt;TCPServer&lt;/strong&gt;, which accepts connections and broadcasts messages, and &lt;strong&gt;TCPClient&lt;/strong&gt;, which provides the chat interface. The project uses Java 21, JavaFX 21.0.9, TCP sockets, and virtual threads.&lt;/p&gt;

&lt;p&gt;The interesting engineering work lies between sending the first message and handling the last disconnection: keeping the interface responsive, separating private commands from broadcasts, supporting read-only connections, and closing resources reliably.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqvu7jltcra80wsaab7jk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqvu7jltcra80wsaab7jk.png" alt="Adnane’s JavaFX client showing a conversation with Sara and an Online indicator." width="683" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A fresh demonstration of the packaged application: Adnane and Sara exchange messages through the TCP server. The application screenshots in this post were captured from the actual project running locally; the conversation is demo data.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping the architecture understandable
&lt;/h2&gt;

&lt;p&gt;I separated presentation, coordination, and networking so that each part has a clear responsibility:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TCPClient
  ClientApplication → ClientController → ChatClient
                                            │
                                   UTF-8 lines over TCP
                                            │
TCPServer                                   ▼
  ServerApplication → ServerController → ChatServer
                                            │
                                ClientHandler per connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application classes create the JavaFX views. Controllers connect button actions and network callbacks to those views. &lt;code&gt;ChatClient&lt;/code&gt;, &lt;code&gt;ChatServer&lt;/code&gt;, and &lt;code&gt;ClientHandler&lt;/code&gt; contain the networking logic without depending on JavaFX.&lt;/p&gt;

&lt;p&gt;That separation also makes the protocol testable without opening a window. A socket-level check can exercise the same server logic used by the dashboard.&lt;/p&gt;

&lt;p&gt;The server dashboard exposes its running status, listening port, connection log, and connected named users. Its user list deliberately represents named participants rather than every socket.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7cv8jxm7wyedoi08ot2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F7cv8jxm7wyedoi08ot2i.png" alt="The server dashboard running on port 3000, listing Adnane and Sara while logging a read-only connection." width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Three clients are connected, but only Adnane and Sara appear in the named-user list. The anonymous connection remains visible in the activity log.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The repository includes &lt;a href="https://github.com/Ad-Bakkou/Multi-Client-Chat/tree/adfd62165dfccdb239aa25cb99b066d1f43f9e97/docs" rel="noopener noreferrer"&gt;PlantUML architecture sources and rendered diagrams&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small protocol over TCP
&lt;/h2&gt;

&lt;p&gt;The client and server communicate using UTF-8 text, &lt;code&gt;BufferedReader&lt;/code&gt;, and &lt;code&gt;PrintWriter&lt;/code&gt;. Each application message occupies one line. That line boundary matters: TCP carries a byte stream, so the application needs its own way to distinguish messages.&lt;/p&gt;

&lt;p&gt;The first line identifies the connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USERNAME:Adnane
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An empty username selects read-only mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;USERNAME:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After the handshake, named users can send normal messages or one of three exact, case-sensitive commands:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Server behavior&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;allUsers&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reply to the requester with the active named users.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;bye&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Close that client’s connection.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;end&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Close that client’s connection.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Any other line&lt;/td&gt;
&lt;td&gt;Add the username and server timestamp, then broadcast it.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The server formats ordinary messages as &lt;code&gt;[HH:mm] username: message&lt;/code&gt;. It broadcasts them to registered clients, including the sender and read-only listeners. Returning the sender’s message through the server keeps the displayed format consistent.&lt;/p&gt;

&lt;p&gt;The production client also rejects embedded carriage returns and newlines in outgoing messages, preserving the one-line framing. The handshake and command routing are implemented in &lt;a href="https://github.com/Ad-Bakkou/Multi-Client-Chat/blob/adfd62165dfccdb239aa25cb99b066d1f43f9e97/TCPServer/src/main/java/ma/chat/server/logic/ClientHandler.java" rel="noopener noreferrer"&gt;&lt;code&gt;ClientHandler&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I used virtual threads
&lt;/h2&gt;

&lt;p&gt;Each connection spends much of its time waiting for the next line. The server assigns a virtual thread to each accepted client, allowing the handler to use straightforward blocking I/O.&lt;/p&gt;

&lt;p&gt;This excerpt comes from the accept loop in &lt;code&gt;ChatServer&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;ClientHandler&lt;/span&gt; &lt;span class="n"&gt;handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ClientHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;connections&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Client connected: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getRemoteSocketAddress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;Thread&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startVirtualThread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The surrounding implementation coordinates acceptance and shutdown with a lifecycle lock. It also uses concurrent sets to track connections safely across handlers.&lt;/p&gt;

&lt;p&gt;Virtual threads suit tasks that spend substantial time waiting for I/O. They do not make individual operations inherently faster, and using them does not establish that an application scales to a particular number of users. This project uses them to keep the connection-handling model simple; it does not include a large-scale performance benchmark. See Oracle’s &lt;a href="https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html" rel="noopener noreferrer"&gt;Java 21 virtual-thread guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making JavaFX responsive and thread-safe
&lt;/h2&gt;

&lt;p&gt;Socket connection, sending, and receiving work runs outside the JavaFX Application Thread. Otherwise, a slow network operation could stop the interface from responding.&lt;/p&gt;

&lt;p&gt;Network callbacks return to the UI through &lt;code&gt;Platform.runLater()&lt;/code&gt;. For example, the client controller registers this listener:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setMessageListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Platform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;runLater&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;closed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messagesArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;runLater()&lt;/code&gt; queues work on the JavaFX Application Thread, as described in the &lt;a href="https://openjfx.io/javadoc/21/javafx.graphics/javafx/application/Platform.html#runLater(java.lang.Runnable)" rel="noopener noreferrer"&gt;JavaFX API documentation&lt;/a&gt;. The &lt;code&gt;closed&lt;/code&gt; guard prevents a queued callback from updating a view that has already been closed.&lt;/p&gt;

&lt;p&gt;The server follows the same pattern. When its user list changes, the queued UI callback reads the &lt;strong&gt;current&lt;/strong&gt; usernames. This avoids restoring an old snapshot after another connection or disconnection has already happened.&lt;/p&gt;

&lt;p&gt;External CSS controls the visual styling. Controllers handle behavior, while the networking classes remain unaware of controls, colors, and layout.&lt;/p&gt;

&lt;h2&gt;
  
  
  Treating read-only access as a server rule
&lt;/h2&gt;

&lt;p&gt;Leaving the username blank connects a listener that can receive broadcasts but cannot send messages or commands.&lt;/p&gt;

&lt;p&gt;The interface communicates this state with a &lt;strong&gt;READ-ONLY MODE&lt;/strong&gt; notice and disabled sending controls. However, disabling a button alone would not enforce the protocol: another client could still write directly to the socket.&lt;/p&gt;

&lt;p&gt;The server therefore checks &lt;code&gt;readOnly&lt;/code&gt; before interpreting every incoming line. An attempted message or command receives a rejection instead of being broadcast or executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F77uo7s814cdqqp37s883.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F77uo7s814cdqqp37s883.png" alt="A read-only client receiving Adnane and Sara’s messages, with its input and SEND button disabled." width="683" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The listener receives the conversation while sending remains disabled. LEAVE is still available.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Anonymous clients are registered broadcast recipients, but their usernames are stored as &lt;code&gt;null&lt;/code&gt; and filtered out of the named-user list. This makes receiving messages and appearing as a named participant separate concerns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keeping allUsers private
&lt;/h2&gt;

&lt;p&gt;An ordinary chat message belongs in the shared conversation. A user-list query only needs a response to the person who requested it.&lt;/p&gt;

&lt;p&gt;The handler implements that distinction directly: &lt;code&gt;allUsers&lt;/code&gt; calls its own &lt;code&gt;sendMessage()&lt;/code&gt; method, while ordinary text calls &lt;code&gt;server.broadcast()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8kr8b15unecj7bg2pwto.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8kr8b15unecj7bg2pwto.png" alt="Adnane’s client showing Active users: Adnane, Sara beneath the shared conversation." width="683" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Adnane requests &lt;code&gt;allUsers&lt;/code&gt; and receives the named-user list.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4yg844n6wlkemai2e0hg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4yg844n6wlkemai2e0hg.png" alt="Sara’s client showing the shared conversation without the private Active users response." width="683" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Sara’s client does not receive that response. The read-only connection is absent from the returned list.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a small routing decision, but it provides a useful pattern for separating shared events from connection-specific replies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connection cleanup is part of the design
&lt;/h2&gt;

&lt;p&gt;The server keeps two concurrent sets with different purposes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;connections&lt;/code&gt; tracks accepted sockets, including clients still waiting to send a username handshake.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;clients&lt;/code&gt; tracks registered broadcast recipients.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That distinction matters during shutdown. Closing only registered clients could leave a handler blocked waiting for its first line. &lt;code&gt;stop()&lt;/code&gt; closes the listening socket and every tracked connection. Handler cleanup removes clients from the sets and triggers a user-list update.&lt;/p&gt;

&lt;p&gt;The implementation also gives the socket ownership of stream cleanup. A writer can be blocked behind a send, so the handler closes the socket first rather than waiting to close the writer first. On the client, closing the socket releases the receiving operation; the controller then updates the connection state.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffbpfn0fmoa7136pr3a6z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffbpfn0fmoa7136pr3a6z.png" alt="Adnane’s client showing Offline and Disconnected from server after the server window closes." width="683" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Closing the server changes the connected client to Offline and disables sending.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;These lifecycle choices are visible in &lt;a href="https://github.com/Ad-Bakkou/Multi-Client-Chat/blob/adfd62165dfccdb239aa25cb99b066d1f43f9e97/TCPServer/src/main/java/ma/chat/server/logic/ChatServer.java" rel="noopener noreferrer"&gt;&lt;code&gt;ChatServer&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://github.com/Ad-Bakkou/Multi-Client-Chat/blob/adfd62165dfccdb239aa25cb99b066d1f43f9e97/TCPClient/src/main/java/ma/chat/client/logic/ChatClient.java" rel="noopener noreferrer"&gt;&lt;code&gt;ChatClient&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the behavior, not just the build
&lt;/h2&gt;

&lt;p&gt;For this write-up, the source at commit &lt;code&gt;adfd621&lt;/code&gt; was built and checked on Windows x64 with Java 21. Both Maven packages built successfully.&lt;/p&gt;

&lt;p&gt;A separate local socket-level verification harness passed &lt;strong&gt;14 checks&lt;/strong&gt;, covering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Timestamped UTF-8 messages and delivery to the sender, another named client, and a read-only client.&lt;/li&gt;
&lt;li&gt;Named-user filtering and private &lt;code&gt;allUsers&lt;/code&gt; responses.&lt;/li&gt;
&lt;li&gt;Server-side rejection of read-only messages and commands.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bye&lt;/code&gt;, &lt;code&gt;end&lt;/code&gt;, invalid handshakes, and accepting a new client after a departure.&lt;/li&gt;
&lt;li&gt;The production &lt;code&gt;ChatClient&lt;/code&gt; handshake and receiving path.&lt;/li&gt;
&lt;li&gt;Server shutdown, including a socket still waiting to complete its handshake.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The packaged JavaFX applications were also exercised directly: two named clients exchanged messages, a read-only client received them, &lt;code&gt;allUsers&lt;/code&gt; stayed private, LEAVE updated the dashboard, and closing the server disconnected the remaining clients.&lt;/p&gt;

&lt;p&gt;These checks were run separately while preparing the article. The repository currently has no committed automated test suite; Maven’s successful build alone is not evidence of functional test coverage. The checks also do not establish behavior under heavy load, across operating systems, or during prolonged network failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Packaging and running the application
&lt;/h2&gt;

&lt;p&gt;The projects use Maven Shade to produce executable JARs with dependencies and resources. Their manifests point to the ordinary &lt;code&gt;TCPServer&lt;/code&gt; and &lt;code&gt;TCPClient&lt;/code&gt; entry-point classes, which resolve configuration before launching JavaFX.&lt;/p&gt;

&lt;p&gt;From the repository root, build each application separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;mvn&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="nc"&gt;TCPServer&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;xml&lt;/span&gt; &lt;span class="n"&gt;clean&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;
&lt;span class="n"&gt;mvn&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="nc"&gt;TCPClient&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kt"&gt;xml&lt;/span&gt; &lt;span class="n"&gt;clean&lt;/span&gt; &lt;span class="n"&gt;package&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;java&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt; &lt;span class="nc"&gt;TCPServer&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;TCPServer&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then start one or more clients in separate terminals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;java&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt; &lt;span class="nc"&gt;TCPClient&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;TCPClient&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;jar&lt;/span&gt; &lt;span class="n"&gt;localhost&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two projects have separate POMs; there is no root aggregator POM. The shaded &lt;code&gt;*-1.0.jar&lt;/code&gt; files are the executable artifacts, while the &lt;code&gt;*-1.0-SNAPSHOT.jar&lt;/code&gt; files are intermediate thin JARs.&lt;/p&gt;

&lt;p&gt;The Windows build includes JavaFX native dependencies, but &lt;strong&gt;does not include a Java runtime&lt;/strong&gt;. The verified environment is Windows x64 with Java 21; another operating system needs an appropriate build and validation. The shaded applications emit an unnamed-module JavaFX configuration warning, which was present during the successful local demonstration.&lt;/p&gt;

&lt;p&gt;Configuration comes from classpath &lt;code&gt;application.properties&lt;/code&gt; resources loaded at startup. Defaults are &lt;code&gt;localhost&lt;/code&gt; and port &lt;code&gt;3000&lt;/code&gt;. Changing packaged defaults requires rebuilding; the client can override its host and port by supplying both command-line arguments. It does not load an arbitrary external properties file from the working directory.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would improve next
&lt;/h2&gt;

&lt;p&gt;This is a focused networking project with clear limits. Usernames are self-declared, duplicates are allowed, and there is no authentication, encryption, message persistence, or automatic reconnection.&lt;/p&gt;

&lt;p&gt;The current broadcast loop writes directly to recipients. A slow reader can delay a broadcast, so a future version could add bounded outgoing queues and a clear policy for slow connections. Concurrent senders also have no explicit global message sequencer.&lt;/p&gt;

&lt;p&gt;My next priorities would be to bring repeatable protocol checks into the repository, add handshake and resource limits, and test slow-reader behavior before making any scalability claims.&lt;/p&gt;

&lt;p&gt;Building the application brought together networking, concurrency, UI coordination, and deployment. The most useful lesson was that a working connection is only one part of the system: each connection also needs an identity, a set of allowed operations, and a predictable way to end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/Ad-Bakkou/Multi-Client-Chat" rel="noopener noreferrer"&gt;Explore the source code on GitHub&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>javafx</category>
      <category>networking</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
