Question
Write two programs, a server and a client, that communicate via a socket.
The server must run an infinite loop that: (1.0%)
- Accepts a socket connection.
- Uses the recv system call to read a single line off the
socket.
- Closes the socket.
- Echos the line out to the screen.
Note that the server does not fork a child to deal with the
connection.
The client must: (1.0%)
- Connect to the server.
- Use the send system call to write a line containing the
client's machine.domain name down the socket.
- Close the socket.
You can use mysockets.h and
mysockets.c to do most of
the detailed socket manipulations (but you must not use the ReadData
and WriteData functions, use recv and send).
Answer