• Jan 17: You can assume that the string length * N is less than BUFSIZE.


In this project, you are going to modify the echo client/server we went over in class so that instead of echoing a single string back to the client, the server now echoes N copies of the string. Your client will then print out how many copies of the string that it received.

Note for clarification purposes: if N=1, then the server should return one copy of the string. If N=2, then the server should return 2 copies, etc. You do not need to support N=0, N negative, or other erroneous conditions.

For this homework, the client should send a NULL byte to signify that the string it is sending is finished. Hint: modify the receiver so it looks for the null byte to signify that the string has been fully received.


  1. Modify the server so that it looks for a NULL byte to know that the string has finished being received.

  2. Modify the server so that it returns N copies of the string that the client sends it, intead of just one copy. N is passed into the server as a command-line argument. See above for clarifications on what N means.

  3. Modify the client so that it prints out the value of N, learned by analyzing the length of the string that the server returns. The only way the client should learn N is by analyzing the server’s reply (not via e.g., a command-line option, internal define, or anything like that). We’ve already included the code that prints N–you just need to calculate it.

You only have to examine the length of the returned string to determine N. We won’t be analyzing or testing the case where the server returns bad data, some fractional portion of the message, or any other error conditions. We will be testing your client with your server. Please don’t modify the printf() statement that prints N.

You don’t have to support negative values of N, N=0, etc.


We are going to check out your code, call ‘make’, and then run the provided binary files (client and server).

You can modify the provided code, but please make sure that “make” works as expected, and don’t change the executable name, the command-line arguments, or the N= printout in the client.

If you have any questions, please let us know.

Starter code

You can accept the HW2 invitation on GitHub which will provide you with the starter code. The link is: