Linux I/O model (5)-select-xuan Mai blade-blog

Source: Internet
Author: User

Linux I/O model (5)-select-xuan Mai blade-blog

Linux I/O model (5)-select of Io Reuse Model
By Xuan Mai blade, 1177 read, 0 comments, favorites, Edit

The first thing you need to know is the select function:
Select Function

# Include <sys/select. h>

# Include <sys/time. h>

Int select (INT maxfd, fd_set * readset, fd_set * writeset, fd_set * predictionset, const struct timeval * timeout );

Return: the number of vertices in the ready description. Value 0 indicates timeout, and value-1 indicates an error.

Parameter description:

Maxfd: the largest file descriptor (the value should be the largest file descriptor word + 1)

Readset: a set of Descriptor words for Kernel read Operations

Writeset: a set of Descriptor words for Kernel write operations

Predictionset: a set of Descriptor words for Kernel exception operations

Timeout: How long does it take to wait for the descriptor to be ready. Null indicates waiting forever. A fixed value indicates waiting for a fixed time. 0 indicates not waiting at all. Return immediately after checking the description.

Note: readset, writeset, and predictionset are both value-result parameters, which means they are passed into the pointer. The function can modify the corresponding fd_set according to the pointer.

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.