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 就可以看到返回的時間了
我也正在學這本書,共同進步,拉拉手先