1.环境说明:macOS 10.14.5
2.源码下载地址:http://www.unpbook.com/src.html
3.解压获的源码 按照README依次编译执行
QUICK AND DIRTY
===============Execute the following from the src/ directory:
1 ./configure # try to figure out all implementation differences
2 cd lib # build the basic library that all programs need
make # use "gmake" everywhere on BSD/OS systems3. cd ../libfree # continue building the basic library
make4. cd ../libroute # only if your system supports 4.4BSD style routing sockets
make # only if your system supports 4.4BSD style routing sockets5. cd ../libxti # only if your system supports XTI
make # only if your system supports XTI6. cd ../intro # build and test a basic client program
make daytimetcpcli
./daytimetcpcli 127.0.0.1If 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.
4. 在执行 第三步时 报错
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o inet_ntop.o inet_ntop.c
inet_ntop.c:56:1: error: conflicting types for 'inet_ntop'
inet_ntop(af, src, dst, size)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/arpa/inet.h:77:13: note: previous declaration is here
const char *inet_ntop(int, const void *, char *, socklen_t);
^
1 error generated.
make: *** [inet_ntop.o] Error 1
解决办法:
找到inet_ntop.c
文件把#include <arpa/inet.h>
这行注释掉,再次执行上述命令,成功!
5.启动服务端程序
6.执行客户端程序
结果如下