Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add epoll_wait info

...

  • -DDEV_PKG=1  turn on development mode.  This causes the header files, and the archive (.a) to be included in the resulting package(s) and/or installed when 'make install' is executed. If this flag is omitted, then a run-time package is generated which does not include the header files or the archives.
  • -DBUILD_DOC=1 this causes the document formatting tool ({X}fm) to be loaded at configuration time, and the RMr man pages to be generated. If the development package option is set, the man pages will be installed such that commands like  man rmr   are available.
  • -DPACK_EXTERNALS=1  Causes the Nanomsg and NNG libraries to be placed into the package and/or installed. (This is meant only for testing and should never be used when generating a deployable package.)
  • -DSKIP_EXTERNALS=0  Causes the build process to assume that Nanomsg and NNG are currently installed in the developement environment and do not need to be explicitly built.


Can I use epoll_wait() to know when messages are ready to receive?   

Yes, when the underlying transport mechanism supports it; NNG supports this.  Calling the RMR function rmr_get_rcvfd() will return a file descriptor which will be "readable" whenever a message is pending and calling rmr_rcv_msg() will not block.  The following code illustrates one way to set up for this.


Code Block
linenumberstrue
   if( (rcv_fd = rmr_get_rcvfd( mrc )) >= 0 ) {            // if a valid fd comes back, set up epoll stuff
        if( rcv_fd < 0 ) {
            fprintf( stderr, "<SNDR> unable to set up polling fd\n" );
            exit( 1 );
        }
        if( (ep_fd = epoll_create1( 0 )) < 0 ) {
            fprintf( stderr, "<SNDR> [FAIL] unable to create epoll fd: %d\n", errno );
            exit( 1 );
        }
        epe.events = EPOLLIN;
        epe.data.fd = rcv_fd;

        if( epoll_ctl( ep_fd, EPOLL_CTL_ADD, rcv_fd, &epe ) != 0 )  {
            fprintf( stderr, "<SNDR> [FAIL] epoll_ctl status not 0 : %s\n", strerror( errno ) );
            exit( 1 );
        }
    }


A word of caution:  the EPOLLET (edge trigger) flag seems not to work with NNG.  NNG will set the FD readable until the queue empties, but doesn't set the edge trigger.