UDP Sample Code

As a demonstration, we've provided the programs client.c and server.c which send and receive UDP packets, respectively. These are loosely based on Figures 6a and 6b from the IPC Tutorial.

Copy these files into your home directory on a Science Center HP workstation, perhaps using the Save Link As... menu item when you click the right mouse button on each link in Netscape. Call them server.c and client.c. Open two windows. In the first:

scws32% gcc -o server server.c
scws32% gcc -o client client.c
scws32% ./server 7009
In the second window, type this, but first replace scws32 with the name of the computer you're using:
scws32% ./client scws32 7009
You should then see this appear in the first window:
from 140.247.31.132: The sea is calm tonight, the tide is full . . .
The point is that client sent that string over the network to server. Try to figure out how the programs work, perhaps using the UNIX manual pages.