Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Centralized Computing System (CCS)

A multithreaded client-server application in Java that demonstrates practical use of both UDP and TCP - using each protocol where it actually fits best - along with concurrent client handling via thread pools.

Overview

The Centralized Computing System (CCS) acts as a compute server: clients discover it on the network, connect, and send arithmetic operation requests (ADD, SUB, MUL, DIV), which the server computes and returns. The server supports multiple concurrent clients and periodically reposts live usage statistics.

Why UDP and TCP?

Rather than picking one protocol for everything, this project uses each where its strengths matter:

  • UDP for service discovery - connectionless and fast, well suited to a quick broadcast-and-response handshake (CCS DISCOVER -> CCS FOUND) before a real connection is established.

  • TCP for client communication - connection-oriented and reliable, ensuring requests and computed results are delivered accurately and in order once a client is talking to the server.

How it works

  1. Start the server:
   java -jar CCS.jar <port>
  1. Start one or more clients, pointed at the same port:
   java -jar CCS.jar <port>
  1. The client broadcasts a CCS DISCOVER message over UDP. The server responds CCS FOUND, and the client then opens a TCP connection to the server.
  2. Once connected, the client sends requests in the form OPER ARG1 ARG2 (e.g. ADD 4 7), and the server responds with the computed result.
  3. Multiple clients can connect and send requests concurrently - the server handles each on its own thread.
  4. Every 10 seconds, the server logs live statistics: number of connected clients, total requests handled, per-operation counts (ADD/SUB/MUL/DIV), invalid request count, and the running sum of all computed values.

Architecture

  • ServiceDiscoveryThread​` - listens for UDP discovery broadcasts and responds to valid clients.
  • CommunicationWithClientThread - accepts incoming TCP connections and hands each client off to its own thread via a dedicated thread pool.
  • **ClientThread - handles a single client's requests: validates input, computes the result, and returns the response.
  • SendStatisticsThread - reports live server statistics on a fixed interval.
  • Shared statistics counters use AtomicInteger to stay thread-safe under concurrent access from multiple client threads.

Tech Stack

  • Java
  • java.net (sockets, datagrams)
  • java.util.concurrent (thread pools, AtomicInteger)

Getting Started

Prerequisites

  • JDK installed
  • Two or more terminal windows/machines on the same network for a realistic multi-client test

Build & Run

git clone https://github.com/dmytrozelinskyy/centralized-computing-system.git
# build with your usual javac/jar workflow, or via your IDE
java -jar CCS.jar <port>

Then, in separate terminals, run the client the same way with the same port.

License

MIT

About

Multithreaded Java client-server system using UDP for service discovery and TCP for reliable client communication, with concurrent request handling via thread pools.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages