Network Function [09] network sending Function Analysis

Source: Internet
Author: User
Tags network function
1 -- Recv function details
# Include <sys/socket. h> ssize_t Recv (INT socket, void * buffer, size_t length, int flags); Return Value:> 0: data is read successfully. Return Value indicates the number of bytes read this time; = 0: this indicates that no data can be read from the current interface and is disabled by the peer.-1: failed to read data. The system sets the errno value, for specific error causes and countermeasures, refer to errno;


When the Recv function returns-1, you must determine errno to determine the response. Next I will try to explain these errno and their causes.

Eagain or ewouldblock
Cause: this error code is generated when the socket is set to a non-blocking link and no data is readable on the current interface.

Countermeasure: if you do not close the current link, place the FD in the listening queue. Wait until it becomes readable and then read it again.

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.