源代碼下載地址http://www.unpbook.com/src.html
最近在看Unix網絡編程,1.2節給了一個簡單的客戶端的例子,功能是利用TCP協議獲取服務器的時間,我先把下載的源代碼到Ubuntu上面,然后解壓
tar -xzvf upv13e.tar.gz
打開解壓的目錄,發現有個readme文件
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.
按照步驟,先執行 ./configure
再進入 lib目錄 cd lib
make
進入libfree目錄 cd ../libfree 然后 make
會有一些警告,忽略就行了,剩下兩個make 不成功也沒關系
后面最重要的一步
./daytimetcpcli 127.0.0.1后發現報錯,Connection Refused
這個版本的Ubuntu默 認是不開daytime服務的,需要開啟daytime服務,就在你當前的目錄ls你可以看到有個daytimetcpsrv文件,執行sudo ./daytimetcpsrv。它的功能就是開啟本機的daytime服務,然后你再開啟一個終端,敲擊./daytimetcpcli 127.0.0.1,就可以看見時間了