In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
The system provides select function to realize the multiplexing input / output model.
The select function lets our program monitor changes in the state of multiple file descriptors. The program stops at select and waits until one or more of the monitored file descriptors have a state change.
The function prototype is as follows:
Return value: the number of ready descriptors returned successfully, 0 after timeout time and no event occurred, and-1 for failure
Parameter explanation:
Nfds: add 1 to the maximum descriptor value in the monitored file descriptor (the descriptor starts at 0, and the descriptors 0, 1, and 2...nfds-1 are all tested)
The following three parameters, readset, writeset, and exceptset, specify the descriptors that we want the kernel to test for read, write, and exception conditions. If you are not interested in a condition, you can set it to a null pointer.
Readfds: read the descriptor set (all descriptors concerned with the read event are added by the user). This parameter is an input-output parameter.
Writefds: write descriptor set
Exceptfds: exception descriptor set
Struct fd_set can be understood as a collection in which file descriptors are stored and can be set by the following four macros:
Void FD_CLR (int fd, fd_set * fdset); / / removes the given file descriptor from the specified collection
Int FD_ISSET (int fd, fd_set * fdset); / / determines whether the specified descriptor is added to the specified set (whether it is readable / writable)
Void FD_SET (int fd, fd_set * fdset); / / adds a given file descriptor to the collection
Void FD_ZERO (fd_set * fdset); / / clear the collection
Timeout: set for a period of time
(1) in the case of timeout=NULL, the current process waits until a descriptor is ready for Imax O (wait forever)
(2) when timeout points to the timeval structure and the time setting is not set to 0, the current process is suspended. If no event occurs at the set time (timeout), the process returns 0, and the process continues to execute the following code (waiting for a fixed period of time).
(3) when timeout points to the timeval structure and the time is set to 0, it will not wait and return immediately (no wait at all)
Struct timeval {
Long tv_sec; / / seconds
Long tv_usec; / / microseconds
}
Server_select.c
# include # define BLOCK 6int fds [64]; void usage (char * proc) {printf ("% s [ip] [port]\ n", proc);} int create_sock (char * port,const char * inaddr) {/ / 1. Int listenfd=socket (AF_INET,SOCK_STREAM,0); if (listenfd
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
1. SSL connection exhaustion tool (thc-ssl-dos) root@kali:~/DDoS_tool/web# thc-ssl-dos-h _
© 2024 shulou.com SLNews company. All rights reserved.