Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in /var/www/html/activities/books/networking/labbook/fac/fac6.php on line 2

Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in /var/www/html/activities/books/networking/labbook/fac/fac6.php on line 2

Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in /var/www/html/activities/books/networking/labbook/fac/fac6.php on line 3

Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in /var/www/html/activities/books/networking/labbook/fac/fac6.php on line 4

Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in /var/www/html/activities/books/networking/labbook/fac/fac6.php on line 5

Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in /var/www/html/activities/books/networking/labbook/fac/fac6.php on line 8

 

 


Douglas E. Comer


Computer Science Department
Purdue University
West Lafayette, IN 47907

webmaster: W. David Laverell


Companion Topics

Home

Book Information

Purpose of Site

Getting Started

Students

Faculty

"What's New"

"Coming Attractions"

"C Pointers"

Acknowledgements

 

 
HON: Faculty Notes to Chapter 6 Home > Faculty > Chapter Notes > Chapter 6

Chapter 6

Chapter 6 Student Notes
6.1 6.2 6.3 6.4
Chapter 6 introduces the student to the details of socket programming. In Experiment 6.1 they are asked to obtain sample code from Purdue University. As in Chapter 5 you may wish to do this for them and provide a local copy.

In Experiment 6.2 students rewrite the version of echo software provided in Chapter 5 to eliminate the simplified API. I found it much easier to modify client.c and server.c provided in this chapter. I also chose (or was it just a dumb mistake) to implement chat rather than echo. That was felicitous since it gave me the opportunity to modify it to satisfy the specifications of the second Optional Extension in Experiment 5.2.

Experiment 6.4 is a good introduction to the differences between the two main protocols, tcp and udp. It is important since Chapter 8, which I use as the semester project, is done using udp. When we went over Chapter 27 in Computer Networks, we spent some time trying to work out a procedure for converting a client/server suite from tcp to udp. That procedure turned out to be very helpful in last year's lab on this topic, and following it let me make the conversion without having worked through it ahead of time and without notes. Next time around they will do it themselves with the following directions:

    For both client and server:

    1. change the string "tcp" to "udp".

    2. change SOCK_STREAM to SOCK_DGRAM.

    3. eliminate receive loops in favor of a simple recv call.

  1. Server:

    1. Take out the calls to listen and accept.

    2. Change send to sendto and recv to recvfrom.

    Client:

    You do not have to make any additional changes to the client, but you may remove the connect call if you change send to sendto and recv to recvfrom.

It might be a good strategy not to give them that last step. They will then encounter the following behavior: the client will be able to contact the server, but the server's response will not get to the client. If they think this through, they should see that without a connection and with the server not saving the client's ip address and port number, the behavior they encounter is exactly what they should have expected.



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