"Learning Environment Building" of UNIX Network Programming Volume 1 (CentOS 7)

Source: Internet
Author: User

"UNIX Network Programming Volume 1" Source code can be downloaded from www.unpbook.com. The directory after decompression is unpv13e.

1. Compiling

To enter the unpv13e directory, compile as follows:

1./Configure2 3 cd Lib4  Make //may encounter problems: redefinition of ' struct in_pktinfo '5 6Cd.. /Libfree7  Make 8   9Cd.. /LibrouteTen  Make //This step can be error, can be ignored, only indicates that your system does not support 4.4BSD, does not affect the study of the book One    ACd.. /Libgai -  Make 

For the above question ' redefinition of ' struct in_pktinfo ', we need to comment out the "struct in_pktinfo" struct declaration in Unpv13e/key/unp.h and Unpv13e/sctp/unp.h , as it has been included in the standard header file Bits/in.h. A recompile is required after the modification.

The above steps will generate a static library Libunp.a.

2. Copy the generated libunp.a static library to/usr/lib/and/usr/lib64/
1 CD.   //  2sudocp libunp.a/usr/3sudocp
3. Modify the Unpv13e/lib/unp.h and copy it and config.h to/usr/include
1 //  2sudocp lib/unp.h/usr/3sudocp
4. Running the example (UNPV13E/INTRO/DAYTIMETCPCLI.C)

  1) compile with static link library:-l parameter plus Libunp.a remove Lib and back. A. Finally get the parameter-LUNP

1 CD./2gcc

  2) test the resulting executable file to get the current date of the machine:

1 127.0. 0.1

The following error occurs when you test:

1 Connect Error:connection refused

  3) This error indicates that the daytime service program is not open and can be xinetd to control the service connection request. The following opens the daytime service program via XINETD.

1 sudo cd/etc/xinetd.d/2sudo vim daytime

If the Xinetd.d folder is empty, you will need to install the XINETD service first:

1 sudo Yum Install xinetd.x86_64

Change disable = Yes in Daytime-stream and daytime-dgram two files to disable = No, save exit and restart XINETD:

1 Service xinetd restart

  4) Test This example again to display the local time successfully:

1 127.0. 0.1 2  A  - : CST

Reference blog:

"Network Programming" on UNIX Network programming volume 1 Unp.h and source code compilation problem

Unix NetWork programming--Environment Building (solve unp.h and other source code compilation problems)

CentOS Open Daytime Server

"Learning Environment Building" of UNIX Network Programming Volume 1 (CentOS 7)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.