慶應義塾大学
2007年度 秋学期

ネットワーク・プログラミング(C言語)
Network Programming in C

2007年度秋学期 火曜日2時限
科目コード: 13070 / 2単位
カテゴリ:
開講場所:SFC
授業形態:講義
担当: Rodney Van Meter
E-mail: rdv@sfc.keio.ac.jp

第11回 1月8日
Lecture 11, January 8

宿題 1/8
Homework for Lecture 11

Note: this homework has been somewhat modified from the originals from Lectures 3 and 4.

This week's homework (submit via email):

  1. Take the program at the top of Lecture 3 and fix it. It does not currently compile. Please copy that to your computer, and debug it. (You may also want to use this as an opportunity to try a source code control system, such as RCS, and my preference is that you send me the solution to this problem as a diff or rcsdiff from the existing program.)
    Your output should look something like this:
    [rdv@localhost network-programming-in-c]$ ./a.out 
    elementNumber: 10
    elementNumber: 9
    elementNumber: 8
    elementNumber: 7
    elementNumber: 6
    elementNumber: 5
    elementNumber: 4
    elementNumber: 3
    elementNumber: 2
    elementNumber: 1
    elementNumber: 0
    
  2. Look for the word Report in the comments in the UDP server code. There is a chunk of code using getnameinfo(), getpeerinfo(), and gai_strerror(). Take that chunk of code and put into the library file mylib.c. I called my function report_mysocket.
  3. Take the TCP server program in Lecture 4, and edit where the comments are to print out information about the connections, and make it use that same function.
  4. Test for errors from the system calls in the above code. Use perror() where appropriate.
  5. You were supposed to create two source files and link them together for your program. This week, we are going to add unit test. We need one more source code file:
    • mylibtest.c
    That file should include a main() function that calls each function in the corresponding source file to test that it works. Now you must compile five separate programs: your TCP client and server, your UDP client and server, and mylibtest. The initial code for mylibtest.c will probably be similar to the TCP server with the error printing.

Additional Information

その他