Write a simple socket server named rwhod, which runs on port 9090 LINUX- The ser
ID: 3715845 • Letter: W
Question
Write a simple socket server named rwhod, which runs on port 9090 LINUX-
The server will print a message before the socket accept on the console "Waiting for client connection"
- After bind/listen/accept, the server will read a message from the client.
- Use a message size of 1024 bytes.
- The message will be a user name
- The server will use the user name to run a command using peopen (who | grep username)
- The server will accept the output from popen and return it to the client.
- If that user is not signed on, return a message that says "The user xxxx is not found."
- You may read the entire contents of the popen command into a buffer of 1024.
- If you get NULL from fgets, you can assume that the user is not found.
- After answering the client:
- close the socket
- print a message "Done serving the client"
- exit the program
Explanation / Answer
Hi, happy to help you! Please ask if any clarifications before rating straightaway.
Here's simple python code that does what you've asked for:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.