UNIX网络编程—源码下载及环境配置
配置环境
本人使用的环境为centos 7.2,所使用的配套书籍为UNIX,网络编程第三版
链接:https://pan.baidu.com/s/1soJqtB7FtXJrMS0bujuusw
提取码:8nom
源码下载及环境配置
本书所使用的全部源码均可在www.unpbook.com下载,本人也做了百度云存档
链接:https://pan.baidu.com/s/1TDnc0qpHqVVI47XdhQvSZw
提取码:957a
下载到Linux后下解压打开
tar -xzvf unpv13e.tar.gz
根据解压后的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</span>
- 如果在…/libfree目录下执行make命令的时候,出现错误:
inet_ntop.c: 在函数‘inet_ntop’中:
inet_ntop.c:60:9: 错误:实参‘size’与原型不符
size_t size;
^
In file included from inet_ntop.c:27:0:
/usr/include/arpa/inet.h:64:20: 错误:原型声明
extern const char *inet_ntop (int __af, const void *__restrict __cp,
那么,只需将size_t size;改为socklen_t size;就可以了。
第一个简单的时间获取程序
cd /intro
make daytimetcpcli
./daytimetcpcli 127.0.0.1
出现响应
08 DEC 2018 16:43:12 CST
如果报错
connect error: Connection refused
则需要打开本地服务器的daytime 功能,操作过程如下:
yum install xinetd
vim /etc/xinetd.d/daytime-stream
在daytime-stream中把disable改成 no 的属性。
再重启xinetd即可
service xinetd restart