السلام عليكم اخوني
اتمنى منكم المساعدة في كتابة هذا البرنامج لان الصراحة خبرتي بالسي ما هي قوية اذا فيه احد يعرف يكتب الاكواد ابغى اكون له شاكر ومقدر.
I want to implement a simple chat room that includes a client and a server.
The client program provides commands: login (allow users to join the chat room),
newuser (create a new user account), send (send a message to other clients; actually send
the message to the server and the server forwards the message to other clients), and
logout (quit the chat room).
The server runs a chat room service, manages all the clients and distributes the messages
I'm going to explain
I nedd to implement a server and a client. The server will use 1 plus the last four digits of
number 1010 . For example, if the last four digits of number is 1010, then as the server
port number is 11010.
In this project, only one active client connects to the server. The following commands
need to be implemented at the client side and the server side implements the
corresponding functions required to support these commands. When the server starts, it
should first read the user account information from a file. the initial
user accounts (UserID, Password) are (Tom, Tom11), (David, David22) and (beth,
beth33).
1. login UserID Password
If the server can verify the UserID and the Password, the server will send a
confirmation message to the client; otherwise, the server will decline login and send
an error message to the client.
2. newuser UserID Password
Create a new user account. The length of the UserID should be less than 32, and the
length of the Password should be between 4 and 8 characters. The server will reject
the request if the UserID is already there. The users’ IDs and passwords should be
kept in a file.
3. send message
Send the “message” to the server. The server will precede the message with the
UserID and send it back.
4. logout
Logout from the chat room. Once logout, the connection between the server and
client will be closed. The server should allow the next client to connect.
Sample client output.
My chat room client. Version One.
>send
>Server: Denied. Please login first.
>login Tom tom11
>Server: Tom joins
>send Hello.
>Tom: Hello.
>send Bye.
>Tom: Bye.
> logout
>Server: Tom left.