Task: Async Server
Navigate to labs/lab-11/tasks/async-server and run make to generate the support files. Enter support and run make test-file.txt to generate the test file.
This task builds on the previous example of a multiplexed client-server. The server accepts connections from clients and downloads a file of 1 GB from each. After uploading the file, the clients close the connection.
-
Open
server.cand complete the TODOs in the main function to setup IO multiplexing usingepoll. Useepoll_create(),epoll_wait(), and the wrappers defined inw_epoll.hto handle descriptors without blocking. Remember to remove the client sockets from theepollinstance before closing them.To test, run
./serverin one terminal and./clientin another terminal.s If successful, the clients should print the upload progress. -
There is a problem with our current implementation. Try to start two clients at the same time - the first one will start uploading, and the second one will block at
connect(). This happens because, even though we are multiplexing file descriptors on the server-side, it is busy with another client. To account for this, complete the TODOs inhandle_client()to serve each client on a different process.To test, start
python server.pyin one terminal and run your client implementation in two separate terminals. If successful, the clients should be able to upload at the same time.
If you’re having difficulties solving this exercise, go through Async I/O and I/O Multiplexing.