运行 Unix网络编程 中的第一个例子 unp学习 实例的运行

来源:互联网 发布:js页面倒计时代码 编辑:程序博客网 时间:2024/05/22 01:45

 运行书本中的程序。
1,首先,进入到Stevens的主页中下载原码
2,然后,编译程序,方法如下:

    tar -zxvf  unpv12e.tar.gz (-C dir)//解压文件

    cd unpv12e
    ./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 ../libgai   # the getaddrinfo() and getnameinfo() functions
    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 daytimetcpsrv

    make daytimetcpcli

此时会生成 daytimetcpsrv daytimetcpsrv.o daytimetcpcli daytimetcpcli.o


3、linux现在因为安全问题,各个发行版本默认是不开daytime服务的。  
   
  第一个例子实际上是两个程序,客户端和服务端,你很有可能只运行了客户端,没有运行服务端程序。  
   
  服务端程序在书上第12页……你不会尚还没有看到那里吧?  
   
  PS:由于要打开端口,所以服务端程序需要用root权限执行,所以你可以先   

    sudo   ./daytimetcpsrv  (如果本身就是root就不需要sudo)

  然后再开一个终端运行   ./daytimetcpcli 127.0.0.1  就可以看到返回的时间了  
   
  我也正在学这本书,共同进步,拉拉手先