How tavolop3/chat works
• Client (client.c)
• Server (server.c)
• Dynamic Array Service (darray from lib/darray.h) used within the server to store and manage user connections.
• Epoll-based multiplexing mechanism
• Threading modules (epoll threads handling connections and a main thread accepting new connections)
Core architecture (focus on client and server, without tests)
• The Client:
• As one separate entity that initiates a connection to the server.
• That the client sends messages and receives broadcast messages from the server.
• The Server:
• A component that uses epoll to monitor multiple file descriptors for incoming communications.
• How the server accepts connections on a primary (main) thread and delegates communication to worker threads (handle threads).
• Use of epoll as a central element where all threads (or at least a thread pool) are monitoring for activity.
• Role of the dynamic array (darray) for storing information about connected clients and facilitating message broadcast.
Incorporate specific technical elements
• “epoll” as an external mechanism or subsystem that ties into the server’s threading model.
• “threading” by showing multiple threads interacting with the epoll instance.
• Optionally, include annotations like “non-blocking I/O” or “efficient handling of high load,” which are central design principles for this project.
Summarize the dynamic
• The Client sends a message over a TCP socket to the Server.
• The Server’s main thread accepts the connection and registers the client's socket with the epoll instance.
• A pool of worker threads, each waiting on the epoll, picks up the incoming message events.
• Upon receiving a message, the server uses the darray-managed list of connections to determine targets and broadcasts the message to every connected client.
• If a client sends a special command ("/u <username>"), the change is processed by the server, possibly updating its state in the darray.