# Chat Application Project
## Project Overview
Build a simple client-server chat application that demonstrates socket programming and TCP communication. This project applies concepts from the transport layer including TCP connections, ports, and sockets.
## Technologies Required
Python 3 with socket library for network programming. The project uses only standard library modules so no additional installation is needed.
## Server Code Description
The server creates a TCP socket and binds it to a specific IP address and port. It listens for incoming connections and accepts them. When a client connects the server creates a new thread to handle that client so multiple clients can connect simultaneously. The server receives messages from each client and broadcasts them to all other connected clients. It maintains a list of all active client connections.
## Client Code Description
The client creates a TCP socket and connects to the server using the server IP address and port number. After connecting it prompts the user to enter a username. It then creates two threads, one to receive messages from the server and display them, and another to read input from the user and send it to the server. This allows the client to send and receive simultaneously.
## Key Concepts Demonstrated
TCP socket creation and binding demonstrates port number usage. The three-way handshake happens automatically when the client connects. Multiple simultaneous connections demonstrate how ports and sockets work together to identify different connections. Broadcasting messages demonstrates how servers can communicate with multiple clients. The project shows why connection-oriented TCP is chosen over UDP for a chat application where message delivery must be guaranteed.
## Testing the Application
Run the server on one terminal. Note the IP address and port it is listening on. Run multiple client instances in separate terminals. Connect each client to the server. Type messages in one client and verify they appear in all other client terminals. Disconnect a client by pressing Control-C and verify other clients continue working.
## Extensions to Try
Add message timestamps. Add private messaging between specific users. Add a list command to show all connected users. Implement message history so new users see recent messages when they join. Add TLS encryption to the communication.Back to Course