-The following short code bit illustrates the use of this
-function. Error checking has been omitted for clarity.
-
-
-::
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/epoll.h>
- #include <rmr/rmr.h>
-
- int main() {
- int rcv_fd; // pollable fd
- void* mrc; //msg router context
- struct epoll_event events[10]; // support 10 events to poll
- struct epoll_event epe; // event definition for event to listen to
- int ep_fd = -1;
- rmr_mbuf_t* msg = NULL;
- int nready;
- int i;
- int norm_msg_size = 1500; // 95% messages are less than this
-
- mrc = rmr_init( "43086", norm_msg_size, RMRFL_NONE );
- rcv_fd = rmr_get_rcvfd( mrc );
-
- ep_fd = epoll_create1( 0 ); // initialise epoll environment
- epe.events = EPOLLIN;
- epe.data.fd = rcv_fd;
- epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ); // add our info to the mix
-
- while( 1 ) {
- nready = epoll_wait( ep_fd, events, 10, -1 ); // -1 == block forever (no timeout)
- for( i = 0; i < nready && i < 10; i++ ) { // loop through to find what is ready
- if( events[i].data.fd == rcv_fd ) { // RMR has something
- msg = rmr_rcv_msg( mrc, msg );
- if( msg ) {
- // do something with msg
- }
- }
-
- // check for other ready fds....
- }
- }
- }
-
+The following short code bit illustrates the use of this
+function. Error checking has been omitted for clarity.
+
+
+::
+
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <sys/epoll.h>
+ #include <rmr/rmr.h>
+
+ int main() {
+ int rcv_fd; // pollable fd
+ void* mrc; //msg router context
+ struct epoll_event events[10]; // support 10 events to poll
+ struct epoll_event epe; // event definition for event to listen to
+ int ep_fd = -1;
+ rmr_mbuf_t* msg = NULL;
+ int nready;
+ int i;
+ int norm_msg_size = 1500; // 95% messages are less than this
+
+ mrc = rmr_init( "43086", norm_msg_size, RMRFL_NONE );
+ rcv_fd = rmr_get_rcvfd( mrc );
+
+ ep_fd = epoll_create1( 0 ); // initialise epoll environment
+ epe.events = EPOLLIN;
+ epe.data.fd = rcv_fd;
+ epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ); // add our info to the mix
+
+ while( 1 ) {
+ nready = epoll_wait( ep_fd, events, 10, -1 ); // -1 == block forever (no timeout)
+ for( i = 0; i < nready && i < 10; i++ ) { // loop through to find what is ready
+ if( events[i].data.fd == rcv_fd ) { // RMR has something
+ msg = rmr_rcv_msg( mrc, msg );
+ if( msg ) {
+ // do something with msg
+ }
+ }
+
+ // check for other ready fds....
+ }
+ }
+ }
+