Experiment 5.3

Chapter Notes
5.1 5.2 5.3
This is one of the less difficult experiments. I started with echoclient.c and echoserver.c and made the obvious modifications. There was really only one wrinkle. When I think of writing a file server, I think in terms of reading the file in seqments of some fixed number of bytes. That will not work in this case due to the simple fact that the function recvln does exactly what you might expect from its name: it reads a line of text which it assumes is terminated by a \n (012). So you need to be careful to use something like fgets. You also need to be careful in computing the number of bytes you send as that newline character must be included. The reason you need to send a newline is that you are dealing with a stream when you use TCP. It has only the structure that you give it. This idea comes up in an important way in the next chapter.

The task of file transfer comes up in later experiments, 6.2, 8.3, and 8.4. You want to do this well as the experience and the code ill be very useful later on.


This site is maintained by by W. David Laverell of the Computer Science Department at Calvin College.
For assistance or corrections, please contact him at lave@calvin.edu.