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

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

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

第8回 12月4日
Lecture 8, December 4: Getting Caught Up

Outline of This Lecture

Apologies

I must apologize and take responsibility for several issues:

Where You Ought to Be

By now, you are supposed to be comfortable with the following tools:

And the following concepts:

...that's a lot for one semester.

Structure of Your System

By now, you should have a complete system fairly well under way. It should consist of the following:

宿題 10/9
Homework From Lecture 2

This week's homework (submit via email):

  1. Begin your term project. Create three source files with the following functions: Compile and run your program. main() should call both SleepALittle() and OpenConnectionToServer(). The other two functions can be dummy functions for now.
  2. Above, we defined the function MakeElementList(). Write a program including the function FreeElementList(), using the library function free().

宿題 10/16
Homework From Lecture 3

This week's homework (submit via email):

  1. Last week, you were supposed to create three source files and link them together for your program. This week, we are going to add unit test. We need two more source code files: Each of those should include a main() function that calls each function in the corresponding source file to test that it works. Now you must compile three separate programs: hotpotato, mylibtest, and networkingtest. Show that each one runs.
  2. The homework "answer" at the top of this page does not actually work. 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.)

宿題 10/23
Homework From Lecture 4

This week's homework (submit via email):

  1. Take the above program, and edit where the comments are to print out information about the connections, using getnameinfo(), getpeerinfo(), and gai_strerror().
  2. Test for errors from the system calls in the above code. Use perror() where appropriate.
  3. Modify the above server so that it calls fork() and creates a second process after accepting the connection. The parent should close() the connection socket and return to waiting for a new connection, while the child should close the initial socket, process the connection, then exit.
  4. Learn to use a wire monitoring tool, such as Wireshark or tcpdump. Capture the packets of two connections to your server to show that both connections are being processed at the same time.

宿題 11/6
Homework From Lecture 5

This week's homework (submit via email):

  1. If you are using a Unix-like environment (including cygwin), and you are not yet using make, create a Makefile like the one above for your programs.
  2. Add a main() to the TCP client example above, and test it with your TCP server.
  3. The UDP client above uses the old-style approach to sockets (AF_INET, htonl(), htons()). Adapt it to use getnameinfo(), as in the TCP client example. This should allow it to operate with IPv6. Don't forget to loop over the possibly multiple return values from getnameinfo().
  4. The UDP client doesn't wait for a response from the server. Adapt it to use recvfrom() to receive a packet from the server, and print out what it gets.

宿題 11/13
Homework From Lecture 6

This week's homework (submit via email):

  1. Test your TCP and UDP clients against my server.
  2. Capture the packet trace.
  3. Create the file mylib.c, if you don't have it, and add the functions report_mysocket() and report_partner() to it, and use them in your TCP and UDP servers.
  4. Create prototypes for those functions and create a matching header file.
  5. Use a more thorough Makefile, with dependencies made automatically. You will need to use GNU make (possibly called gmake) to use this file.

宿題 11/27
Homework From Lecture 7

This week's homework (submit via email):

  1. Compile the example program from the IBM website and report whether your machine is big endian or little endian.
  2. Adapt your TCP client and server programs to use htonl() and ntohl() to send and receive binary data correctly, as well.

Next Lecture

第7回 11月13日
Lecture 7, November 13: Binary data encodings

Additional Information

その他