How akashkinkarpandey/netchatplusplus works
Project type and purpose
• NetChatPlusPlus is a C++-based, real-time, multi-client chat application built on a classic client-server architecture.
• It leverages WinSock2 for TCP networking and uses multithreading to achieve full-duplex, concurrent message handling.
File structure
• Top-level files:
• server.cpp – the server implementation (listens for connections, dispatches messages)
• client.cpp – the client implementation (connects to server, sends/receives messages)
• README.md – project overview, how-to
• No separate “lib” or “src” folders—everything lives in two modules.
• The presence of only two .cpp files suggests a monolithic server and a monolithic client.
README for additional insights
• Clarifies that the server:
• Initializes WinSock
• Binds & listens on a TCP port
• Accepts client connections and spawns a thread (or worker) per client
• Relays incoming messages to all connected clients
• The client:
• Connects to the server
• Runs two threads—one for sending user input, another for listening/displaying incoming messages
a. Main components
• Client Application (console-based UI + networking threads)
• Server Application (listening thread + per-client worker threads + message broadcast logic)
• Networking Layer (TCP/IP via WinSock2 on Windows)
• Operating System / Winsock Library (WinSock2 DLL)
• (Future) External Services: optional TLS/SSL layer, database for chat history
b. Relationships & interactions
• Each client opens a TCP socket to the server’s IP:port
• Server’s listener thread performs accept(), spawns a worker thread per client
• Client send-thread → socket → Server worker thread → broadcast queue → all other server worker threads → their sockets → client receive-threads
• All data flows over the network “cloud” (TCP/IP)
c. Architectural patterns & principles
• Concurrency Model: thread-per-connection (scalable to client count)
• Network I/O: blocking sockets (could evolve to non-blocking or IOCP)
• Message Broker Pattern: server acts as a simple in-memory broker, relaying messages to subscribers (clients)
d. Key technologies & libraries
• C++17 (or C++14/11 depending on compiler)
• WinSock2 (winsock2.h, ws2_32.lib)
• STL threads (<thread>, <mutex>)
• g++ (MinGW) on Windows