当前位置:网站首页>Select function
Select function
2022-07-02 20:29:00 【wwwlyj123321】
usage :int select(int maxfdp,fd_set *readfds,fd_set *writefds,fd_set *errorfds,struct timeval *timeout);
effect : Used to monitor the file descriptors we need to monitor ( File descriptors in the read or write file set ) Change of state . And can tell us through the returned value .
Parameter interpretation :
int maxfdp
: The range of all file descriptors in the collection , Add... To the maximum of all file descriptors 1.
fd_set *readfds
: Read file set to monitor .
fd_set *writefds
: Set of write files to monitor .
fd_set *errorfds
: Used to monitor abnormal data .
struct timeval* timeout
:select Timeout for , It can make select In three states :
- First of all , If the NULL Pass in as a formal parameter , That is to say, the time structure is not introduced , Namely take select Put it in a blocked state , Be sure to wait until a file descriptor in the set of monitored file descriptors changes ;
- second , If the time value is set to 0 second 0 millisecond , It becomes a pure non blocking function , Whether or not the file descriptor changes , All immediately return to continue execution , File no change return 0, Change returns a positive value ;
- Third ,timeout The value is greater than 0, This is the waiting timeout , namely select stay timeout During the blocking time , When an event arrives within the timeout period, it returns , Otherwise, after the timeout, it must return anyway .
struct timeval timeout; timeout.tv_sec = 0; // second timeout.tv_usec = dwTimeout * 1000; // Microsecond 1 millisecond = 1000 Microsecond
Return value Introduction :
>0: The monitored file descriptor has changed , The return bit is still 1 Of fd Total of .
-1: error
0 : Overtime
give an example :
REF
select The function and fd_set Introduce - cs_wu - Blog Garden
Select Analysis of function realization principle _liitlefrogyyh The column -CSDN Blog
边栏推荐
- for(auto a : b)和for(auto &a : b)用法
- 什么叫在线开户?现在网上开户安全么?
- [internship] solve the problem of too long request parameters
- Use graalvm native image to quickly expose jar code as a native shared library
- The metamask method is used to obtain account information
- Motivation! Big Liangshan boy a remporté le prix Zhibo! Un article de remerciement pour les internautes qui pleurent
- Talk about macromolecule coding theory and Lao Wang's fallacy from the perspective of evolution theory
- Outsourcing for three years, abandoned
- Automated video production
- I would like to ask what securities dealers recommend? Is it safe to open a mobile account?
猜你喜欢
八年测开经验,面试28K公司后,吐血整理出高频面试题和答案
Summary of interview experience, escort your offer, full of knowledge points
Resunnet - tensorrt8.2 Speed and Display record Sheet on Jetson Xavier NX (continuously supplemented)
为什么我对流程情有独钟?
Redis sentinel cluster working principle and architecture deployment # yyds dry goods inventory #
API documentation tool knife4j usage details
接口测试到底怎么做?看完这篇文章就能清晰明了
Driverless learning (4): Bayesian filtering
Conscience summary! Jupyter notebook from Xiaobai to master, the nanny tutorial is coming!
[871. Minimum refueling times]
随机推荐
想问问,现在开户有优惠吗?在线开户是安全么?
【Hot100】21. Merge two ordered linked lists
In depth understanding of modern web browsers (I)
For (Auto A: b) and for (Auto & A: b) usage
GCC: Graph Contrastive Coding for Graph Neural NetworkPre-Training
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of the inverted front fork of the global market in 2022
Implementation of online shopping mall system based on SSM
Esp32c3 crash analysis
What are the preferential account opening policies of securities companies now? Is it actually safe to open an account online?
[internship] solve the problem of too long request parameters
C language linked list -- to be added
What is the Bluetooth chip ble, how to select it, and what is the path of subsequent technology development
JS how to get integer
At compilation environment setup -win
Cron表达式(七子表达式)
台湾SSS鑫创SSS1700替代Cmedia CM6533 24bit 96KHZ USB音频编解码芯片
Review of the latest 2022 research on "deep learning methods for industrial defect detection"
Notes on hardware design of kt148a voice chip IC
AcWing 341. Optimal trade solution (shortest path, DP)
Research Report on the overall scale, major manufacturers, major regions, products and applications of battery control units in the global market in 2022