[Previous] [Contents] [Index] [Next]

select_attach()

Attach a file descriptor to a file handle

Synopsis:

#include <sys/iofunc.h>
#include <sys/dispatch.h>

int select_attach 
        ( void *dpp,
          select_attr_t *attr,
          int fd,
          unsigned flags,
          int (*func)( select_context_t *ctp,
                      int fd,
                      unsigned flags,
                      void *handle ),
          void *handle );

Library:

libc

Description:

The function select_attach() attaches the file descriptor fd to the dispatch handle dpp and selects flags events. When fd "unblocks", func is called with handle.

select_attr structure

Here's what the select_attr structure looks like:

typedef struct _select_attr {
   unsigned                 flags;
} select_attr_t;

Currently, no attribute attr->flags are defined.

flags

The available flags are defined in <sys/dispatch.h>. The following flags use ionotify() mechanisms (see ionotify() for further details):

SELECT_FLAG_EXCEPT
Out-of-band data is available. The definition of out-of-band data is resource manager specific.
SELECT_FLAG_READ
There's input data available. The amount of data available defaults to 1. For a character device like a serial port this would be a character. For a POSIX message queue it would be a message. Each resource manager will select an appropriate object.
SELECT_FLAG_WRITE
There's room in the output buffer for more data. The amount of room available needed to satisfy this condition is resource manager specific. Some resource managers may default to an empty output buffer while others may choose some percentage of the empty buffer.

These flags are specific to dispatch:

SELECT_FLAG_REARM
Rearm the fd after an event is dispatched.
SELECT_FLAG_SRVEXCEPT
Registers a function that's called whenever a server, to which this client is connected, dies. (This flag uses the ChannelCreate() function's _NTO_CHF_COID_THREADDEATH flag. In this case, fd is ignored.)

func

The argument func is the user-supplied function that's called when one of the registered events occurs on fd. This function should return 0 (zero), other values are reserved. The function is passed the following arguments:

ctp
Context pointer.
fd
The fd on which the event occurred.
flags
Indicates the type of event that occurred. The possible flags are:

See the flags section above for descriptions of the flags passed to func.

handle
The handle passed to select_attach().

handle

The argument handle is a pointer to data that's passed to func.

Returns:

Zero on success, or -1 if an error occurred (errno is set).

Errors:

EINVAL
Invalid argument.
ENOMEM
Insufficient memory was available.

Examples:

For an example with select_attach(), see dispatch_create(). For other examples using the dispatch interface, see message_attach(), resmgr_attach(), and thread_pool_create().

Classification:

QNX 6

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

select_detach(), select_query()


[Previous] [Contents] [Index] [Next]