Diff for /wikisrc/tutorials/kqueue_tutorial.mdwn between versions 1.2 and 1.3

version 1.2, 2012/02/05 07:14:36 version 1.3, 2019/04/05 00:06:57
Line 52  The EV_SET() macro is provided for ease  Line 52  The EV_SET() macro is provided for ease 
     EV_SET(&ev, sckfd, EVFILT_READ, EV_ADD, 0, 0, 0);      EV_SET(&ev, sckfd, EVFILT_READ, EV_ADD, 0, 0, 0);
           
   
 [![][18]][19]  
   
    [18]: /images/Kevent.png  
    [19]: /images/Kevent.png (Kevent.png)  
   
 If we liked to monitor a set of N sockets we would write something like this:   If we liked to monitor a set of N sockets we would write something like this: 
           
     kevent ev[N];      kevent ev[N];
Line 66  If we liked to monitor a set of N socket Line 61  If we liked to monitor a set of N socket
        EV_SET(&ev[i], sckfd[i], EVFILT_READ, EV_ADD, 0, 0, 0);         EV_SET(&ev[i], sckfd[i], EVFILT_READ, EV_ADD, 0, 0, 0);
           
   
 [![][20]][21]  
   
    [20]: /images/Kevent2.png  
    [21]: /images/Kevent2.png (Kevent2.png)  
   
 ##   kqueue(2)  ##   kqueue(2)
   
 The kqueue holds all the events we are interested in. Therefore, to begin with, we must create a new kqueue. We do so with the following code:   The kqueue holds all the events we are interested in. Therefore, to begin with, we must create a new kqueue. We do so with the following code: 
Line 156  The above code would turn into the follo Line 146  The above code would turn into the follo
   
 Note that if one uses a non-NULL zero timespec structure, the kevent() will return instantaneously, bringing down the performance to the levels of a plain poll method.   Note that if one uses a non-NULL zero timespec structure, the kevent() will return instantaneously, bringing down the performance to the levels of a plain poll method. 
   
 ##   Summary  
   
 To summarize, the kqueue framework works like this:   
   
 [![][22]][23]  
   
    [22]: /images/Summary.png  
    [23]: /images/Summary.png (Summary.png)  
   
 #   Examples  #   Examples
   
 ##   A timer example  ##   A timer example
Line 246  We will implement a raw tcp client using Line 227  We will implement a raw tcp client using
   1. any incoming host data in the socket     1. any incoming host data in the socket 
   2. any user data in the standard input stream     2. any user data in the standard input stream 
   
 [![][24]][25]      #include <netinet/in.h>
       
    [24]: /images/Tcpclient.png  
    [25]: /images/Tcpclient.png (Tcpclient.png)  
   
 #include <netinet/in.h>  
     #include <sys/event.h>      #include <sys/event.h>
     #include <sys/socket.h>      #include <sys/socket.h>
     #include <sys/time.h>      #include <sys/time.h>

Removed from v.1.2  
changed lines
  Added in v.1.3


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb