Background

In the digital age, chat applications are essential for real-time communication, whether for personal conversations, professional collaboration, or social networking. These applications often rely on client-server architectures where the server handles incoming messages from multiple clients, and the clients send and receive messages from one another.

In this assignment, you will gain hands-on experience with socket programming, multi-threading, and basic client-server design. By implementing a chat application in C, you will deepen your understanding of how communication between computers works over a network.

Objective

The objective of this assignment is to implement a basic chat application that uses C sockets to enable client-server communication. Specifically, you will:

  1. Create a server that listens for incoming client connections.
  2. Develop a client application that connects to the server to send and receive messages.
  3. Explore multi-threading by ensuring that the server can handle multiple clients simultaneously.
  4. Learn how messages are passed over TCP/IP using sockets.

Server Implementation

1. Socket Creation and Binding

2. Handling Multiple Clients

3. Message Handling

4. Graceful Client Termination

Client Implementation

1. Socket Creation

2. User Input

3. Message Sending

4. Receiving Messages

5. Exit Command (Extra Credit)

Technical Specifications

Simple Testing Procedure

  1. Start the Server:
    • Compile and run the server using the provided instructions.
    • The server should output a message indicating that it is listening for connections, such as:
      Server is listening on port 9090...
      
  2. Start Multiple Clients:
    • Compile and run the client code in different terminal windows.
    • Each client should connect to the server and be able to send messages.
    • Messages sent from one client should be echoed back and visible on all connected clients’ terminals.
  3. Testing Multiple Clients:
    • Test with at least three clients to ensure the server is properly broadcasting messages to all connected clients.

Grading Criteria

Functionality (60%)

Code Quality (20%)

Documentation (20%)

Code Snippets

Grading Submission


Suggested Improvements/Extensions: