Considerations for using the Write function in Linux socket programming

Source: Internet
Author: User

Many people think that using write and sending data using send is the same, and you can actually send data, but one thing to note:

The Write function does not guarantee that the sent data can be sent at once, possibly sending only a portion (when the kernel sends a buffer full), which destroys the "atomicity" of the data sent, which is only the process of sending a single packet that is not affected by other send operations. If the middle is interrupted, then the other threads on the same socket will be sent to the sending operation, resulting in the final packet confusion. So it's best to send it using send.

But it is not that send will not be interrupted, the send operation will be interrupted when there is information coming in the process of sending.

Considerations for using the Write function in Linux socket programming

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.