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

运行书本中的程序。
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

其中  daytimetcpsrv  , daytimetcpcli可执行文件  而 daytimetcpsrv.o,daytimetcpcli.o 为编译后产生的中间文件。



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

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

  然后再开一个终端运行   ./daytimetcpcli 127.0.0.1  就可以看到返回的时间了  
   
  我也正在学这本书,共同进步,拉拉手先
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章