In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article will analyze "what does select refer to in Ipaw O Multiplexing". The content is detailed and easy to understand, and friends who are interested in "what does select refer to in Igamot O Multiplexing" can follow the editor's train of thought to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "what does select refer to in Icano multiplexing".
Select is used to monitor changes in the state of multiple file descriptors. This is used to monitor whether the file descriptor read / write / exception state is ready.
Function prototype: int select (int nfds,fd_set * readfds,fd_set * writefds,fd_set * exceptfds,struct timeval * timeout)
Several disadvantages of select:
(1) every time you call select, you need to copy the fd collection from the user mode to the kernel state. This overhead will be very large in many cases of fd.
(2) at the same time, each call to select requires traversing all the fd passed in the kernel, which is also very expensive in many cases when fd is called.
(3) the number of file descriptors supported by select is too small
1 # include 2 # include 3 # include 4 # include 5 # include 67 int main () 8 {9 int std_in = 0; 10 / / int std_out = 1; 11 fd_set reads; 12 / / fd_set writes; 13 / / int max_nums = std_out; 14 int max_nums = std_in; 15 FD_ZERO (& reads); 16 / / FD_ZERO (& writes); 17 FD_SET (std_in,&reads) 18 / / FD_SET (std_out,&writes); 19 struct timeval _ timeout = {5 int done 0}; 20 int done = 0; 21 while (! done) 22 {23 _ timeout.tv_sec = 5; 24 _ timeout.tv_usec = 0 25 / / switch (select (max_nums+1,&reads,&writes,NULL,&_timeout)) 26 switch (select (max_nums+1,&reads,NULL,NULL,&_timeout)) 27 {28 case-1: 29 perror ("select"); 30 break; 31 case 0: 32 printf ("timeout...\ n") 33 break; 34 default://success 35 {36 if (FD_ISSET (std_in,&reads)) 37 {/ / read 38 char buf [1024]; 39 memset (buf,'\ 0recording journal sizeof (buf)) 40 ssize_t size = read (std_in,buf,sizeof (buf)-1); 41 if (size
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.