博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Unix网络编程示例代码使用

Posted on 2010-10-31 20:13  darren_xiahx  阅读(649)  评论(0)    收藏  举报

0. To extract the source directories from the unpv12e.tar.gz tar file,
  execute:

 

cd <some-directory-of-your-choosing>
gunzip -c unpv12e.tar.gz | tar -xvf -

  This creates a directory named unpv12e/ containing about 40 other
  directories. The names of these 40 other directories are what appears
  in the horizontal rules that start and end each source code listing
  in the book. For example, the file unpv12e/intro/daytimetcpcli.c
  corresponds to the source code in Figure 1.5 (Page 6) of the book.

1. There is a "unp.h" header that appears in every one of the 40 directories.
  If you need to make any changes to this "unp.h" header, notice that it
  is a hard link in each directory, so you only need to change it once.
  Hard links are also used with the other "unp*.h" headers.

2. I used the GNU autoconf package to generate a shell script named
  "configure" that you must execute. This script will try and figure
  out lots of characteristics of your system.

  This script builds two important files "Make.defines" and "config.h".
  Each "Makefile" in each of the 40 directories includes "Make.defines",
  and the first #include done by "unp.h" is of "config.h".

  These two files *must* be set correctly for your system, or you will
  not be able to build the source code.

3. 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).

  Go into the "libfree/" directory and type "make". This adds to the
  "libunp.a" library. Similarly go into the "libgai", "libroute" and
  "libxti" directories and "make". The "libroute" directory should only
  be used if your system supports 4.4BSD-style routing sockets. The
  "libxti" directory should only be used if your system supports XTI
  (not TLI).

4. Once the library is made, you can then go into any of the source code
  directories and make whatever program you are interested in. A good
  starting poing is the "intro" directory and "make daytimetcpcli".