《Unix网络编程卷1-套接字联网API》是本好书。
但是第一个例子不是很好编译。
需要如下步骤:
本人机器CentOS 5.4
1.下载源码 unpv13e解压到任意目录
然后按其readme文件操作
./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
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
看到成功显示时间