《Unix网络编程卷1-套接字联网API》第一个例子编译 不通过问题解决
?《Unix網絡編程卷1-套接字聯網API》是本好書。
但是第一個例子不是很好編譯。
需要如下步驟:
本人機器CentOS 5.4
1.下載源碼 unpv13e解壓到任意目錄
然后按其readme文件操作
./configure # try to figure out all implementation differencescd lib # build the basic library that all programs needmake # use "gmake" everywhere on BSD/OS systemscd ../libfree # continue building the basic librarymakecd ../libroute # only if your system supports 4.4BSD style routing socketsmake # only if your system supports 4.4BSD style routing socketscd ../libxti # only if your system supports XTImake # only if your system supports XTIcd ../intro # build and test a basic client programmake daytimetcpcli./daytimetcpcli 127.0.0.1
?
2.#./configure? ? 如果出現
# try to figure out all implementation differences
? ???沒太明白什么意思。今天打開一看,原來是一個腳本。所以大家只需在unix寫入configure然后按回車(注意先讓configure有執行權限 chmod 777 configure)??
#chmod 777 configure
?
3.cd? ? lib? ?
? ?? ?make
? ?? ?開始編譯(這回應該沒有問題)
4.cd??../libfree
? ???make
5.在源代碼中只有libgai和libroute。分別進入每個目錄,敲make。有可能編譯不放,沒有什么事,這是由于你的系統不支持一些環境。
6.這步是測試書上第5頁,第一個程序
? ?cd??../intro
? ???make daytimetcpcli
? ? ./daytimetcpcli 127.0.0.1(本機)
?
注意:如果出現如下提示
[root@localhost intro]# ./daytimetcpcli 127.0.0.1
connect error: Connection refused
那么是你的daytime服務沒有開啟!
?
7.進入 /etc/xinetd.d/daytime? 有2個文件修改
disable yes 改為 disable no
?
重啟 xinetd 服務就行了!
#service xinetd? restart?? 這是centOS 下的
下面是關于xinetd說明
=================
service daytime start? 或者
/etc/init.d/daytime star
輸入命令ntsysv,將daytime打上星號
進入/etc/xinetd.d目錄: cd /etc/xinetd.d 執行命令service xinetd restart
也可以直接在xinetd.d目錄下找到文件daytime 將參數disable值改為no保存,
執行命令service xinetd restart
什么是xinetd
xinetd即extended internet daemon,xinetd是新一代的網絡守護進程服務程序,又叫超級Internet服務器。經常用來管理多種輕量級Internet服務。xinetd提供類似于inetd+tcp_wrapper的功能,但是更加強大和安全。
================
?
這個時候再次
#./daytimetcpcli 127.0.0.1
看到成功顯示時間
總結
以上是生活随笔為你收集整理的《Unix网络编程卷1-套接字联网API》第一个例子编译 不通过问题解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《感兴二首》第二句是什么
- 下一篇: xinetd 说明