前言
最近在学网络编程,于是下了一本《UNIX网络编程第一卷:套接口API (第3版)》,书中的内容哦高写得很不错,但是毕竟是学代码,不试着调试调试怎么玩呢?但是书上列出的代码根本不好运行,于是百度以后,找到了这个地址:源码下载
拿到源码以后发现看不懂,不过幸好有README;
现在就是使用的问题了,我用的操作系统是Linux Mint17 (64bit),按理说是没有什么问题的;下面具体讲讲需要做的事情咯
正文
首先,解压源码,这里就放到主目录下了咯:wei@wei-Lenovo-G480:~/project/unixNet > tar -xvf unpv13e.tar.gz
接着,咱们先看看目录下的README文档咯:
QUICK AND DIRTY
===============
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.
Notice that all the source code assumes tabs every 4 columns, not 8.
简单明了,不过我在运行到
make daytimetcpcli
的时候还是出了问题
connect error: Connection refused
这种情况说明服务器没有启动daytime服务!那Ubuntu如何启动,daytime服务呢?
sudo apt-get install xinetd
sudo vi /etc/xinetd.d/daytime( 把 disable = yes 改成 no就行了)
sudo /etc/init.d/xinetd restart
完美运行!!