当前位置:网站首页>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
边栏推荐
- Second hand housing data analysis and prediction system
- After writing 100000 lines of code, I sent a long article roast rust
- API文档工具knife4j使用详解
- 有时候只查询一行语句,执行也慢
- Data preparation for behavior scorecard modeling
- Implementing yolox from scratch: dataset class
- Istio deployment: quickly start microservices,
- Share several map bed websites for everyone to share pictures
- Jetson XAVIER NX上ResUnet-TensorRT8.2速度与显存记录表(后续不断补充)
- 自动化制作视频
猜你喜欢

sql-labs

Web3js method to obtain account information and balance

【实习】解决请求参数过长问题

外包干了三年,废了...

Implementing yolox from scratch: dataset class

Motivation! Big Liangshan boy a remporté le prix Zhibo! Un article de remerciement pour les internautes qui pleurent

AcWing 340. Solution to communication line problem (binary + double ended queue BFS for the shortest circuit)

疫情封控65天,我的居家办公心得分享 | 社区征文

CS5268完美代替AG9321MCQ Typec多合一扩展坞方案

Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)
随机推荐
在消费互联网时代,诞生了为数不多的头部平台的话
Function, function, efficiency, function, utility, efficacy
Sometimes only one line of statements are queried, and the execution is slow
Postman接口测试实战,这5个问题你一定要知道
CRM Customer Relationship Management System
JDBC | Chapter 4: transaction commit and rollback
B端电商-订单逆向流程
API documentation tool knife4j usage details
I want to ask you, where is a better place to open an account in Dongguan? Is it safe to open a mobile account?
pytorch 模型保存的完整例子+pytorch 模型保存只保存可訓練參數嗎?是(+解决方案)
接口测试到底怎么做?看完这篇文章就能清晰明了
通信人的经典语录,第一条就扎心了……
[871. Minimum refueling times]
After 65 days of closure and control of the epidemic, my home office experience sharing | community essay solicitation
What is online account opening? Is it safe to open an account online now?
Research Report on the overall scale, major manufacturers, major regions, products and applications of sliding door dampers in the global market in 2022
有时候只查询一行语句,执行也慢
Interested parties add me for private chat
SBT tutorial
八年测开经验,面试28K公司后,吐血整理出高频面试题和答案