"TCP/IP high-efficiency programming: 44 Tips for improving network programs" source code compilation on Linux

Source: Internet
Author: User

In order to complete the compilation first, the following steps are required:

1. Go to the Linux subdirectory and perform make. (This step is patching.) )

2, return to the previous level directory, open file simplec.c, add header file #include <stdio.h>.

3. Remove static from the static void set_address in the following file:

Connectto.c

Tcpsink.c

3. Perform make at the root directory.

Carries mistake one:

When doing Shutdownc/tcpecho experiments, the client SHUTDOWNC always outputs an error:

Shutdownc:fputs failed

It's completely different from what the book says about "server disconnected."

The relevant code is at line 50th SHUTDOWN.C:

if (Fputs (Lin, stdout))
Error (1, errno, "Fputs failed");

Look at Fputs's Man Handbook, you know:

Fputs () return a non-negative number on success, or EOF on error

So change to:

            if (Fputs (lin, stdout) = = EOF                ) 1 " Fputs failed " );

Recompile, then do the experiment, the output is consistent with the book:

Shutdownc:server disconnected

"TCP/IP high-efficiency programming: 44 Tips for improving network programs" source code compilation on Linux

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.