Skip to content

Commit

Permalink
Original content from book's tar file
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Rudoff committed Jan 14, 2020
0 parents commit 97c658e
Show file tree
Hide file tree
Showing 791 changed files with 84,101 additions and 0 deletions.
11 changes: 11 additions & 0 deletions DISCLAIMER
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY

The authors and publisher of the book "UNIX Network Programming" have
used their best efforts in preparing this software. These efforts
include the development, research, and testing of the theories and
programs to determine their effectiveness. The authors and publisher
make no warranty of any kind, express or implied, with regard to
these programs or the documentation contained in the book. The authors
and publisher shall not be liable in any event for incidental or
consequential damages in connection with, or arising out of, the
furnishing, performance, or use of these programs.
41 changes: 41 additions & 0 deletions Make.defines.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# This file is generated by autoconf from "Make.defines.in".
#
# This is the "Make.defines" file that almost every "Makefile" in the
# source directories below this directory include.
# The "../" in the pathnames actually refer to this directory, since
# "make" is executed in all the subdirectories of this directory.
#
# System = @host@

CC = @CC@
CFLAGS = -I../lib @CFLAGS@
LIBS = @LIBUNP@ @LIBS@
LIBS_XTI = @LIBUNPXTI@ @LIBUNP@ @LIBS_XTI@
RANLIB = @RANLIB@

# Following is the main library, built from all the object files
# in the lib/ and libfree/ directories.
LIBUNP_NAME = @LIBUNP_NAME@

# Following is the XTI library, built from all the object files
# in the libxti/ directory.
LIBUNPXTI_NAME = @LIBUNPXTI_NAME@

# Following are all the object files to create in the lib/ directory.
LIB_OBJS = @LIB_OBJS@

# Following are all the object files to create in the libfree/ directory.
LIBFREE_OBJS = @LIBFREE_OBJS@

# Following are all the object files to create in the libgai/ directory.
LIBGAI_OBJS = @LIBGAI_OBJS@

# Following are all the object files to create in the libroute/ directory.
LIBROUTE_OBJS = @LIBROUTE_OBJS@

# Following are all the object files to create in the libxti/ directory.
LIBXTI_OBJS = @LIBXTI_OBJS@

CLEANFILES = core core.* *.core *.o temp.* *.out typescript* \
*.lc *.lh *.bsdi *.sparc *.uw
11 changes: 11 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include ./Make.defines

all:
@echo "Nothing to make in this directory"
@echo "Please read the README file"

clean:
rm -f $(CLEANFILES)

distclean:
rm -f $(CLEANFILES) config.cache config.log config.status config.h Make.defines Makefile
115 changes: 115 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
QUICK AND DIRTY
===============

Execute the following from the src/ directory:

./configure # try to figure out all implementation differences

cd lib # build the basic library that all programs need
make # use "gmake" everywhere on BSD/OS systems

cd ../libfree # continue building the basic library
make

cd ../libroute # only if your system supports 4.4BSD style routing sockets
make # only if your system supports 4.4BSD style routing sockets

cd ../libxti # only if your system supports XTI
make # only if your system supports XTI

cd ../intro # build and test a basic client program
make daytimetcpcli
./daytimetcpcli 127.0.0.1

If all that works, you're all set to start compiling individual programs.

Notice that all the source code assumes tabs every 4 columns, not 8.

MORE DETAILS
============

5. If you need to make any changes to the "unp.h" header, notice that it
is a hard link in each directory, so you only need to change it once.

6. Go into the "lib/" directory and type "make". This builds the library
"libunp.a" that is required by almost all of the programs. There may
be compiler warnings (see NOTES below). This step is where you'll find
all of your system's dependencies, and you must just update your cf/
files from step 1, rerun "config" and do this step again.

6. Go into the "libfree/" directory and type "make". This adds to the
"libunp.a" library. The files in this directory do not #include
the "unp.h" header, as people may want to use these functions
independent of the book's examples.

8. Once the library is made from steps 5 and 6, you can then go into any
of the source code directories and make whatever program you are
interested in. Note that the horizontal rules at the beginning and
end of each program listing in the book contain the directory name and
filename.

BEWARE: Not all programs in each directory will compile on all systems
(e.g., the file src/advio/recvfromflags.c will not compile unless your
system supports the IP_RECVDSTADDR socket option). Also, not all files
in each directory are included in the book. Beware of any files with
"test" in the filename: they are probably a quick test program that I
wrote to check something, and may or may not work.

NOTES
-----

- Many systems do not have correct function prototypes for the socket
functions, and this can cause many warnings during compilation.
For example, Solaris 2.5 omits the "const" from the 2nd argument
to connect(). Lots of systems use "int" for the length of socket
address structures, while Posix.1g specifies "size_t". Lots of
systems still have the pointer argument to [sg]etsockopt() as a
"char *" instead of a "void *", and this also causes warnings.

- SunOS 4.1.x: If you are using Sun's acc compiler, you need to run
the configure program as

CC=acc CFLAGS=-w CPPFLAGS=-w ./configure

Failure to do this results in numerous system headers (<sys/sockio.h>)
not being found during configuration, causing compile errors later.

- If your system supports IPv6 and you want to run the examples in the
book using hostnames, you must install the latest BIND release. You
can get it from ftp://ftp.vix.com/pub/bind/release. All you need from
this release is a resolver library that you should then add to the
LDLIBS and LDLIBS_THREADS lines.

- IPv6 support is still in its infancy. There may be differences
between the IPv6 sockets API specifications and what the vendor
provides. This may require hand tweaking, but should get better
over time.

- If your system supports an older draft of the Posix pthreads standard,
but configure detects the support of pthreads, you will have to disable
this by hand. Digital Unix V3.2C has this problem, for example, as it
supports draft 4, not the final draft.

To fix this, remove wrappthread.o from LIB_OBJS in "Make.defines" and
don't try to build and run any of the threads programs.

COMMON DIFFERENCES
------------------

These are the common differences that I see in various headers that are
not "yet" at the level of Posix.1g or X/Open XNS Issue 5.

- getsockopt() and setsockopt(): 5th argument is not correct type.

- t_bind(): second argument is missing "const".

- t_connect(): second argument is missing "const".

- t_open(): first argument is missing "const".

- t_optmsmg(): second argument is missing "const".

- If your <xti.h> defines the members of the t_opthdr{} as longs,
instead of t_uscalar_t, some of the printf formats of these value
might generate warnings from your compiler, since you are printing
a long without a corresponding long format specifier.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2004/12/12
213 changes: 213 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
dnl ##################################################################
dnl Our macro to check for a function prototype in a given header.
dnl
AC_DEFUN(AC_CHECK_FUNC_PROTO,
[AC_CACHE_CHECK(for $1 function prototype in $2, ac_cv_have_$1_proto,
AC_EGREP_HEADER($1, $2,
ac_cv_have_$1_proto=yes,
ac_cv_have_$1_proto=no))
if test $ac_cv_have_$1_proto = yes ; then
ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`_PROTO
AC_DEFINE_UNQUOTED($ac_tr_func)
fi
])

dnl ##################################################################
dnl We cannot use the AC_CHECK_TYPE macros because AC_CHECK_TYPE
dnl #includes only <sys/types.h>, <stdlib.h>, and <stddef.h>.
dnl Unfortunately, many implementations today hide typedefs in wierd
dnl locations: Solaris 2.5.1 has uint8_t and uint32_t in <pthread.h>.
dnl SunOS 4.1.x has int8_t in <sys/bitypes.h>.
dnl So we define our own macro AC_UNP_CHECK_TYPE that does the same
dnl #includes as "unp.h", and then looks for the typedef.
dnl
dnl This macro should be invoked after all the header checks have been
dnl performed, since we #include "confdefs.h" below, and then use the
dnl HAVE_foo_H values that it can #define.
dnl
AC_DEFUN(AC_UNP_CHECK_TYPE,
[AC_MSG_CHECKING(if $1 defined)
AC_CACHE_VAL(ac_cv_type_$1,
AC_TRY_COMPILE(
[
#include "confdefs.h" /* the header built by configure so far */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#endif],
[ $1 foo ],
ac_cv_type_$1=yes,
ac_cv_type_$1=no))
AC_MSG_RESULT($ac_cv_type_$1)
if test $ac_cv_type_$1 = no ; then
AC_DEFINE($1, $2, $3)
fi
])

dnl ##################################################################
dnl The following checks for any typedefs for XTI programs.
dnl We perform all the #includes that "libxti/unpxti.h" performs.
dnl
AC_DEFUN(AC_UNPXTI_CHECK_TYPE,
[AC_MSG_CHECKING(if $1 defined)
AC_CACHE_VAL(ac_cv_type_$1,
AC_TRY_COMPILE(
[
#include "confdefs.h" /* the header built by configure so far */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
#ifdef HAVE_STDIO_H
# include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
# include <sys/filio.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#ifdef HAVE_PTHREAD_H
# include <pthread.h>
#endif
#ifdef HAVE_POLL_H
# include <poll.h>
#endif
#ifdef HAVE_XTI_H
# include <xti.h>
#endif
#ifdef HAVE_NETCONFIG_H
# include <netconfig.h>
#endif
#ifdef HAVE_NETDIR_H
# include <netdir.h>
#endif
#ifdef HAVE_STROPTS_H
# include <stropts.h>
#endif],
[ $1 foo ],
ac_cv_type_$1=yes,
ac_cv_type_$1=no))
AC_MSG_RESULT($ac_cv_type_$1)
if test $ac_cv_type_$1 = no ; then
AC_DEFINE($1, $2, $3)
fi
])
Loading

0 comments on commit 97c658e

Please sign in to comment.