Create a connection to a channel
#include <sys/iofunc.h>
#include <sys/dispatch.h>
int message_connect( dispatch_t * dpp,
                     int flags );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The message_connect() function creates a connection to the channel used by dispatch handle dpp. This function calls the ConnectAttach() kernel call. To detach the connection ID, you can call ConnectDetach().
A connection ID used by the message primitives, or -1 if an error occurs (errno is set).
#include <sys/dispatch.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
        
int main( int argc, char **argv ) {
   dispatch_t    *dpp;
   int           flags, coid, id;
    
   if( ( dpp = dispatch_create() ) == NULL ) {
     fprintf( stderr, 
        "%s: Unable to allocate dispatch context.\n",
        argv[0] );
     return EXIT_FAILURE;
   }
   id = resmgr_attach ( … );
    
   …
   if ( (coid = message_connect ( dpp, flags )) == -1 ) {
      fprintf ( stderr, "Failed to create connection \
                to channel used by dispatch.\n");
      return 1;
   }
   /* else connection to channel used by dispatch is created */
            
   …
}
For examples using the dispatch interface, see dispatch_create(), message_attach(), resmgr_attach(), and thread_pool_create().
| Safety: | |
|---|---|
| Cancellation point | Yes | 
| Interrupt handler | No | 
| Signal handler | No | 
| Thread | Yes | 
Dispatch dpp must block on messages.