《unix网络编程》(1)源代码的使用方法

来源:互联网 发布:java ssh2默认端口 编辑:程序博客网 时间:2024/05/25 12:22

《unix网络编程(卷1)》源码下载地址

可以从这里免费下载源码

Ubuntu下源码的使用方法

将下载的源码在Ubuntu下解压;控制台内进入解压后源码所在的目录。

打开文件README,其内容如下:

QUICK AND DIRTY===============Execute the following from the src/ directory:   //依次执行下面的./configure;cd lib、make;cd ../libfree、 make命令   ./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命令    cd ../intro    # build and test a basic client program    //执行下面的make daytimetcpcli;./daytimetcpli命令    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.MORE DETAILS============5.  If you need to make any changes to the "unp.h" header, notice that it    is a hard link in each directory, so you only need to change it once.6.  Go into the "lib/" directory and type "make".  This builds the library    "libunp.a" that is required by almost all of the programs.  There may    be compiler warnings (see NOTES below).  This step is where you'll find    all of your system's dependencies, and you must just update your cf/    files from step 1, rerun "config" and do this step again.6.  Go into the "libfree/" directory and type "make".  This adds to the    "libunp.a" library.  The files in this directory do not #include    the "unp.h" header, as people may want to use these functions    independent of the book's examples.8.  Once the library is made from steps 5 and 6, you can then go into any    of the source code directories and make whatever program you are    interested in.  Note that the horizontal rules at the beginning and    end of each program listing in the book contain the directory name and    filename.    BEWARE: Not all programs in each directory will compile on all systems    (e.g., the file src/advio/recvfromflags.c will not compile unless your    system supports the IP_RECVDSTADDR socket option).  Also, not all files    in each directory are included in the book.  Beware of any files with    "test" in the filename: they are probably a quick test program that I    wrote to check something, and may or may not work.NOTES------ Many systems do not have correct function prototypes for the socket  functions, and this can cause many warnings during compilation.  For example, Solaris 2.5 omits the "const" from the 2nd argument  to connect().  Lots of systems use "int" for the length of socket  address structures, while Posix.1g specifies "size_t".  Lots of  systems still have the pointer argument to [sg]etsockopt() as a  "char *" instead of a "void *", and this also causes warnings.- SunOS 4.1.x: If you are using Sun's acc compiler, you need to run  the configure program as        CC=acc CFLAGS=-w CPPFLAGS=-w ./configure  Failure to do this results in numerous system headers (<sys/sockio.h>)  not being found during configuration, causing compile errors later.- If your system supports IPv6 and you want to run the examples in the  book using hostnames, you must install the latest BIND release.  You  can get it from ftp://ftp.vix.com/pub/bind/release.  All you need from  this release is a resolver library that you should then add to the  LDLIBS and LDLIBS_THREADS lines.- IPv6 support is still in its infancy.  There may be differences  between the IPv6 sockets API specifications and what the vendor  provides.  This may require hand tweaking, but should get better  over time.- If your system supports an older draft of the Posix pthreads standard,  but configure detects the support of pthreads, you will have to disable  this by hand.  Digital Unix V3.2C has this problem, for example, as it  supports draft 4, not the final draft.  To fix this, remove wrappthread.o from LIB_OBJS in "Make.defines" and  don't try to build and run any of the threads programs.COMMON DIFFERENCES------------------These are the common differences that I see in various headers that arenot "yet" at the level of Posix.1g or X/Open XNS Issue 5.- getsockopt() and setsockopt(): 5th argument is not correct type.- t_bind(): second argument is missing "const".- t_connect(): second argument is missing "const".- t_open(): first argument is missing "const".- t_optmsmg(): second argument is missing "const".- If your <xti.h> defines the members of the t_opthdr{} as longs,  instead of t_uscalar_t, some of the printf formats of these value  might generate warnings from your compiler, since you are printing  a long without a corresponding long format specifier.

按照上述注释部分的命令执行。

最后运行:./daytimetcpcli 127.0.0.1会出现如下的错误:

yang@ubuntu:~/C++/unix_network/intro$ ./daytimetcpcli 127.0.0.1connect error: Connection refused
解决方法:

Ubuntu启动daytime服务1. sudo apt-get install xinetd2. sudo vi /etc/xinetd.d/daytime, change disable = yes to no3. sudo /etc/init.d/xinetd restart
再次运行./daytimetcpcli 127.0.0.1,结果如下:

yang@ubuntu:~/C++/unix_network/intro$ ./daytimetcpcli 127.0.0.115 MAR 2015 20:21:06 CST


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 华为微信分身版本过低怎么办 手机连接不上4g网络怎么办办 手机通话时老返回锁屏怎么办 小米手机指纹解锁按键不灵了怎么办 小米手机4s黑屏开不了机怎么办 手机老年机突然黑屏开不了机怎么办 苹果7P遮挡传感器就黑屏怎么办 手机被偷支付宝的钱被偷怎么办 oppo手机微信视频黑屏了怎么办 小米账号锁死插卡不显示卡怎么办 红米手机充电时不黑屏怎么办 酷派手机开机出现系统错误怎么办 乐视1s手机开不了机怎么办 酷派手机的信息文件夹不见了怎么办 酷派手机开机卡在开机界面怎么办 魅蓝拨号键老是闪退怎么办 手机上浏览器搜索时字在右边怎么办 酷比魔方平板开不开机怎么办 红米手机摔了有一角黑屏了怎么办 红米手机刷机黑屏打不开怎么办 魅蓝x一打电话就黑屏怎么办 红米手机黑屏打不开怎么办充电发烫 小米手机打电话来是关机的怎么办 红米手机打电话自动灭屏怎么办 红米5s手机白屏怎么办 红米手机黑屏开不了机怎么办 红米note开机键不灵了怎么办 红米2忘记锁屏密码怎么办 红米1手机忘记锁屏密码怎么办 红米4x关不了机怎么办 红米4a手机屏幕黑屏打不开怎么办 红米手机为什么开不了机怎么办 红米note手机刷机失败怎么办 金立手机来电屏幕不亮怎么办 小米5s桌面相机图标不见了怎么办 小米手机锁屏密码忘了怎么办? 小米平板电脑锁屏密码忘了怎么办 小米手机进水了黑屏了嗡嗡响怎么办 华为诺娃2手机声音小怎么办 华为平板锁屏密码忘记了怎么办 华为麦芒6手机按键摔坏了怎么办