These are functions that don't directly work with sockets, but that
one often needs when programming sockets.
- HOSTS: Converting between host name and IP address
- IP address manipulation:
- inet_ntoa: convert IP address from binary format to text string:
- inet_addr: convert IP address from text string to binary format.
In gethostbyaddr
- PORTS: Mapping service names to ports (e.g., on which port is TFTP?)
- INTERRUPTS: Signals and alarms
- TIME: Getting and displaying the current time: the gettimeofday and
ctime functions. In alarm.c.
- CHILD PROCESSES
- fork function. Demonstrated in wait.c.
- wait function: if the child dies before the parent calls the
wait function, the child becomes a zombie (or defunct). The
program wait.c lets you demonstrate
this.
- select: when waiting for input from more than one possible
source. This is one way for a server to handle more than one client
at a time.
In POSIX-compliant systems, there is a similar function called
pselect.
- VARARGS/STDARG: how to write functions that accept a variable number of
arguments.
The famous printf function is a example of a
function that needs one of these mechanisms, because it does not know in
advance how many arguments it will be passed, nor what type they
will be.
varargs is an older mechanism, and is supported both by
SunOS cc and GNU C (gcc). Do man varargs for more
information. stdarg has similar syntax.
It is part of the ANSI C standard, and
thus is supported by GNU C. However, it is NOT supported by SunOS cc.
- BYTE MANIPULATION: these are similar to functions
strncpy, strncmp, etc. However the str* functions
are for text. The following are either for text or for binary data:
- b*
- bzero: initialize a block of bytes to zero
- bcopy: copies a block of bytes to another address
- bcmp: compares 2 blocks of bytes
- mem*
- memset: initialize a block of memory to a given
value. This is more flexible than bzero above,
because you can choose the initial value.
- memcpy: similar to bcopy.
- memove: similar to memcpy.
- memcp: similar to bcmp.
INCLUDE FILES
Here are some include files you might find useful in writing programs
for this lab. Most of them are under the directory /usr/include, but
some might be under /usr/local/include. These files are for SunOS; I
can't guarantee that they exist on other flavors of UNIX.
In addition, I do not necessarily mention include files that are
mentioned in the man pages of the various functions you might call.
- #include <arpa/tftp.h>
- #include <sys/socket.h>
- #include <sys/param.h>