Linux network Programming (1): How to use "Unp.h" __HTML5

Source: Internet
Author: User

As the saying goes, the beginning is difficult, learning new knowledge is the same, when we are determined to implement the example in UNP, it is not very frustrating to find that the program is not deployed. This article is used to give myself this kind of Linux rookie literacy.


First of all, UNP Source link to click on the open link, download completed using the TAR-ZXVF command for decompression.

$ TAR-ZXVF unpv13e.tar.gz
After the decompression is complete, enter the directory.

$ CD unpv13e
For beginners, a look at the software package so many documents, will certainly confused, this is what the NI is used to do. No hurry, the first thing is to read the README.

Execute the following from the Src/directory:

    ./configure    # Try to figure out all implementation differences

    cd Lib         # build the basic library, 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    # Builds and test a basic client program make
    daytimetcpcli
    ./daytimetcpcli 127.0.0.1

If all th At works, your ' re all set to start compiling individual programs.

Notice that all the source code assumes tabs every 4 columns, not 8.

The first step is of course./configure to check the system files, and so on. Why is this so much like using the source code installation file, we are not only using Unp.h this header file. Well, how can Daniel's head paper be the same as a rookie's humble head?

Then follow the steps of the Readme step-by-step, I only compiled the base library under Lib, when make is complete, we will find that when made is completed prompts

Ranlib.. /libunp.a

Libunp.a? What the hell is this, right, this is a static link file. At this point someone is sure to question: Static link is used to do what. This is complicated, give everyone a hint, Baidu "from code to executable file process", "dynamic link and static link difference". Next, go into the Advio folder and try to make daytimetcpcli, as the readme says, and we'll find the process as follows:

Gcc-i.. /lib-g-o2-d_reentrant-wall-o daytimetcpcli daytimetcpcli.o. /libunp.a-lpthread

Smart as you immediately came up from this command to think about how to use GCC in your new folder to compile the example of UNP.

Gcc-o daytimetcpcli (executable) daytimetcpcli.c (c source file)/usr/lib/ Libunp.a (my own Libunp.a location), and then according to Config.h and unp.h specific location, to edit Unp.h #include "". /config.h ", so I am happy to knock open the door of UNIX network programming.




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.