UNIX网络编程(第3版)环境搭建

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 systems

   3. cd ../libfree  # continue building the basic library
    make

   4.  cd ../libroute # only if your system supports 4.4BSD style routing sockets
    make           # only if your system supports 4.4BSD style routing sockets

   5.  cd ../libxti   # only if your system supports XTI
    make           # only if your system supports XTI

   6.  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.

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.执行客户端程序

结果如下

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值