zoukankan      html  css  js  c++  java
  • 《UNIX网络编程卷1》第一例及问题

    《UNIX网络编程卷1》一上来就给了一个例子,新手不容易看懂,估计作者也没有打算让人看懂,作了详尽的解释。新手都想运行这个程序,我也是。
    首先,给的程序都是在unix下运行的。这里有全书代码。
    我的环境是VMware Workstation 12.5.0 + ubuntu 16.04 LTS,已经装了gcc。

    • 先按照/unpv13e/unpv13e/README文件里面的流程走一遍:
    tsc@tsc:~/bin/unpv13e/unpv13e$ ./configure
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    checking for gcc... gcc
    ...
    ...
    tsc@tsc:~/bin/unpv13e/unpv13e$ cd lib
    tsc@tsc:~/bin/unpv13e/unpv13e/lib$ make
    ...
    tsc@tsc:~/bin/unpv13e/unpv13e/lib$ cd ../libfree
    tsc@tsc:~/bin/unpv13e/unpv13e/libfree$ make
    gcc -I../lib -g -O2 -D_REENTRANT -Wall   -c -o inet_ntop.o inet_ntop.c
    inet_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' failed
    make: *** [inet_ntop.o] Error 1
    tsc@tsc:~/bin/unpv13e/unpv13e/libfree$ cd ../libroute
    tsc@tsc:~/bin/unpv13e/unpv13e/libroute$ make
    gcc -I../lib -g -O2 -D_REENTRANT -Wall   -c -o get_rtaddrs.o get_rtaddrs.c
    In 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' failed
    make: *** [get_rtaddrs.o] Error 1
    
    tsc@tsc:~/bin/unpv13e/unpv13e/libroute$ cd ../libxti
    bash: cd: ../libxti: 没有那个文件或目录
    tsc@tsc:~/bin/unpv13e/unpv13e/libroute$ cd ../intro
    tsc@tsc:~/bin/unpv13e/unpv13e/intro$ make daytimetcpcli
    
    tsc@tsc:~/bin/unpv13e/unpv13e/intro$ ./daytimetcpcli 127.0.0.1
    connect error: Connection refused
    

    可以看到提示了错误connect error: Connection refused这里有讨论这个错误的。接下来:

    • 先编译和运行daytimetcpsrv:
    tsc@tsc:~/bin/unpv13e/unpv13e/intro$ make daytimetcpsrv
    gcc -I../lib -g -O2 -D_REENTRANT -Wall   -c -o daytimetcpsrv.o daytimetcpsrv.c
    gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrv daytimetcpsrv.o ../libunp.a -lpthread
    tsc@tsc:~/bin/unpv13e/unpv13e/intro$ sudo ./daytimetcpsrv

    参考:make的作用

    • 再编译和运行daytimetcpcli:
    tsc@tsc:~/bin/unpv13e/unpv13e/intro$ ./daytimetcpcli 127.0.0.1
    Fri Mar  3 20:37:48 2017

    可以看到,给出了系统当前时间,第一例运行成功。

  • 相关阅读:
    对数 简化运算
    term frequency–inverse document frequency
    全量 非全量 计算结果
    指纹识别
    Learning string similarity measures for gene/protein name dictionary look-up using logistic regression
    Modeling of Indoor Positioning Systems Based on Location Fingerprinting
    Surpassing Human-Level Face Verification Performance on LFW with GaussianFace
    perl 访问类方法的几种方式
    perl 访问类方法的几种方式
    perl use base 代替 @ISA
  • 原文地址:https://www.cnblogs.com/shanchuan/p/8150294.html
Copyright © 2011-2022 走看看