CSCB09 Week 12 Lab

In this lab, you will use select() to complete a simple version of nc in client mode!

Task

The program should take 2 command line arguments: dot-notation IP address and port to connect to. The starter code babync.c has already done this and opened a connection.

Then it should use a select() loop to perform:

Do not exit until both stdin and the socket are EOF when reading.

Do not monitor an FD for reading if it reached EOF in the past, lest you would cause busy-polling. (Why?)

Please consult the Testing Tips section in Assignment 4 for testing tips.

You should also use redirection to test for data corruption. Example:

Then IN1 and OUT1 should be identical, IN2 and OUT2 should be identical.

Debugging And Error Messages

If you like to print debugging or error messages for your own sake, please send them to stderr only.

Handing In

The code file babync.c.