Uploaded by CHARLAPALLI UDAY

CN Assignment: Client-Server Communication with Threads

advertisement
CN ASSIGNMENT-5
NAMES:
SERVER:
Client_1: :RAHUL
ROLL NO:
B.AJAY VARDAN
22CS02013
P. RAHUL NAIK
22CS01068
CH. UDAY
22CS01067
MD ARSHAD
22CS01025
Client_2: : AJAY
Client_3: : UDAY
CLIENT_1
1. Interactive Menu:
CLIENT_1 has a menu to let users choose between sending private messages or
broadcasting to all.
2. Real-Time Message Reception:
CLIENT_1 uses a separate thread to continuously receive messages without blocking.
3. Message Types:
CLIENT_1 supports private messages (using @username) and broadcasts (@all).
4. Username System:
CLIENT_1 asks users for a username to identify them on the server.
5. Thread Usage:
CLIENT_1 uses threads for better interaction, allowing tasks like receiving and sending
messages to happen at the same time.
SERVER1
1. One vs Many Clients:
server.c can only handle one client at a time, while SERVER1 manages many clients at
once using threads.
2. Thread Usage:
server.c processes one client sequentially, but SERVER1 creates a thread for each client,
allowing simultaneous communication.
3. Advanced Messaging:
SERVER1 allows both broadcast messages (@all) and private messages (@username),
which server.c doesn’t support.
4. Timeout Handling:
SERVER1 disconnects inactive clients automatically after a set time, while server.c has no
such feature.
Client Management:
SERVER1 keeps a list of all connected clients, using threads and mutex locks to manage
them. server.c doesn’t have a system to track multiple clients.
FUNCTIONS:
Enhanced Communication: Functions like broadcast_message() and private_message()
enable advanced messaging features such as group chat and private chat.
Concurrency: Functions like handle_client() and accept_clients() leverage threading to
allow multiple clients to interact with the server simultaneously.
Resource Management: remove_client() and timeout_checker() prevent resource
wastage by handling disconnections and inactivity.
User Experience: handle_menu() and receive_messages() in CLIENT_1 create an
interactive and dynamic user experience.
1.
Download