Five risks in Linux socket programming

Source: Internet
Author: User
Five risks in Linux socket programming-general Linux technology-Linux programming and kernel information. The following is a detailed description. Socket API is a standard API used in network application development. Although this API is simple, developers may experience some common problems. This article identifies some of the most common risks and shows you how to avoid them.
On the 4.2 BSD UNIX®For the first time introduced in the operating system, Sockets API is now a standard feature of any operating system. In fact, it is difficult to find a modern language that does not support Sockets APIs. This API is quite simple, but new developers still encounter some common risks.

This article identifies the risks and shows you how to avoid them.

Hazard 1. Ignore returned status

The first hidden danger is obvious, but it is the easiest mistake for new developers. If you ignore the return status of the function, you may be lost when they fail or are partially successful. In turn, this may spread errors, making it difficult to locate the source of the problem.

Capture and check each returned status, rather than ignoring them. Consider the example shown in Listing 1, a socket send function.


Listing 1. Ignore the status returned by the API Function
QUOTE:
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.