您的位置:首页 > 理论基础 > 计算机网络

《Unix网络编程卷1-套接字联网API》第一个例子编译

2015-07-24 21:32 676 查看
第一个例子:一个简单的时间获取客户程序,利用GCC编译会出错,需要查看源码中的README文档。

下载源码 unpv13e解压,可看到README文档,打开可看到:

Execute the following from the src/ directory:

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

If all that works, you're all set to start compiling individual programs.


进入到unpv13e的目录中

1、$ ./configure 执行。会出现权限不够的提醒,用chmod 777 修改权限即可,然后执行通过

2、cd lib

make

通过

3、cd ../libfree

make

通过

4、接下来的两次make不是必须的,敲make。有可能编译不通过,我的只通过了 libroute,后一个未通过。

5、执行最后一步

cd ../intro

make daytimetcpcli

./daytimetcpcli 127.0.0.1

发现出错—–connect error: Connection refused

解决方法:

因为系统默认的daytime服务是关闭的,在这个目录下有一个daytimetcpsrv.c文件, 执行make,编译后执行daytimetcpsrv,即sudo ./daytimetcpsrv。它的功能就是开启本机的daytime服务,再次执行./daytimetcpcli 127.0.0.1 h会通过。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: