《UNIX网络编程卷1》第一例及问题
来源:互联网 发布:js实现格式化html代码 编辑:程序博客网 时间:2024/04/30 06:01
《UNIX网络编程卷1》一上来就给了一个例子,新手不容易看懂,估计作者也没有打算让人看懂,作了详尽的解释。新手都想运行这个程序,我也是。
首先,给的程序都是在unix下运行的。这里有全书代码。
我的环境是VMware Workstation 12.5.0
+ ubuntu 16.04 LTS
,已经装了gcc。
- 先按照
/unpv13e/unpv13e/README
文件里面的流程走一遍:
tsc@tsc:~/bin/unpv13e/unpv13e$ ./configurechecking build system type... x86_64-unknown-linux-gnuchecking host system type... x86_64-unknown-linux-gnuchecking for gcc... gcc......tsc@tsc:~/bin/unpv13e/unpv13e$ cd libtsc@tsc:~/bin/unpv13e/unpv13e/lib$ make...tsc@tsc:~/bin/unpv13e/unpv13e/lib$ cd ../libfreetsc@tsc:~/bin/unpv13e/unpv13e/libfree$ makegcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o inet_ntop.o inet_ntop.cinet_ntop.c: In function ‘inet_ntop’:inet_ntop.c:60:9: error: argument ‘size’ doesn’t match prototype size_t size; ^In file included from inet_ntop.c:27:0:/usr/include/arpa/inet.h:64:20: error: prototype declaration extern const char *inet_ntop (int __af, const void *__restrict __cp, ^<builtin>: recipe for target 'inet_ntop.o' failedmake: *** [inet_ntop.o] Error 1tsc@tsc:~/bin/unpv13e/unpv13e/libfree$ cd ../libroutetsc@tsc:~/bin/unpv13e/unpv13e/libroute$ makegcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o get_rtaddrs.o get_rtaddrs.cIn file included from get_rtaddrs.c:1:0:unproute.h:3:45: fatal error: net/if_dl.h: 没有那个文件或目录compilation terminated.<builtin>: recipe for target 'get_rtaddrs.o' failedmake: *** [get_rtaddrs.o] Error 1tsc@tsc:~/bin/unpv13e/unpv13e/libroute$ cd ../libxtibash: cd: ../libxti: 没有那个文件或目录tsc@tsc:~/bin/unpv13e/unpv13e/libroute$ cd ../introtsc@tsc:~/bin/unpv13e/unpv13e/intro$ make daytimetcpclitsc@tsc:~/bin/unpv13e/unpv13e/intro$ ./daytimetcpcli 127.0.0.1connect error: Connection refused
可以看到提示了错误connect error: Connection refused
,这里有讨论这个错误的。接下来:
- 先编译和运行
daytimetcpsrv
:
tsc@tsc:~/bin/unpv13e/unpv13e/intro$ make daytimetcpsrvgcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpsrv.o daytimetcpsrv.cgcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrv daytimetcpsrv.o ../libunp.a -lpthreadtsc@tsc:~/bin/unpv13e/unpv13e/intro$ sudo ./daytimetcpsrv
参考:make的作用
- 再编译和运行
daytimetcpcli
:
tsc@tsc:~/bin/unpv13e/unpv13e/intro$ ./daytimetcpcli 127.0.0.1Fri Mar 3 20:37:48 2017
可以看到,给出了系统当前时间,第一例运行成功。
0 0
- 《UNIX网络编程卷1》第一例及问题
- Unix 网络编程卷1
- 《UNIX网络编程 第一卷》第一个例子
- unix网络编程卷1 问题杂集
- 《UNIX网络编程(卷一)》第一至六章学习笔记
- unix网络编程第一卷代码初使用【转】
- 读书笔记之《UNIX网络编程 第一卷》第三章
- unix网络编程第一卷——chapter 3
- UNIX网络编程:卷1-读书笔记
- Unix网络编程卷1源代码使用
- Unix网络编程(卷1)—笔记
- 《UNIX网络编程 卷1》 笔记: 广播
- 《UNIX网络编程 卷1》 笔记: 线程
- 《Unix网络编程卷1-套接字联网API》第一个例子编译 不通过问题解决
- 《Unix网络编程卷1-套接字联网API》第一个例子编译 不通过问题解决
- 《Unix网络编程卷1-套接字联网API》第一个例子编译
- UNIX网络编程卷1:套接字联网API-第一部分:简介
- UNIX网络编程卷1:套接字联网API-第一部分:下载unpv13e编译运行
- PAT (Advanced Level) Practise 1011 World Cup Betting
- [LeetCode]Kth Largest Element in an Array
- 数组
- Boost库的简介与安装
- C/C++子函数参数传递,堆栈帧、堆栈参数详解_1
- 《UNIX网络编程卷1》第一例及问题
- 洛谷 P1339 [USACO09OCT]热浪Heat Wave(用Dij)
- 1005. 继续(3n+1)猜想 (25)
- CF
- 记录当前项目lua内存泄露问题
- Socket网络编程(多客户端、信息共享、文件传输)
- 读取文件内容到list (commons-io)
- okhttp+“图灵机器人API” 实现智能聊天
- 汉诺塔III 和 汉诺塔IV