Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/select_query.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/select_query.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/select_query.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/select_query.html on line 8
Decode the last select event
#include <sys/iofunc.h>
#include <sys/dispatch.h>
int select_query
( select_context_t *ctp,
int *fd,
unsigned *flags,
int (**func)( select_context_t *ctp,
int fd,
unsigned flags,
void *handle ),
void **handle );
- ctp
- A pointer to a select_context_t structure that defines
the context of the event that you want to get information about.
- fd
- A pointer to a location where the function can store the file
descriptor that's associated with the event.
- flags
- A pointer to a location where the function can store the flags
associated with the event; see
“Flags”
in the documentation for select_attach().
- func
- A pointer to a location where the function can store the function
associated with the event; see
“Function”
in the documentation for select_attach().
- handle
- A pointer to a location where the function can store the address of
any data that you arranged to pass to func.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The function select_query()
stores the values of the last select event, for context ctp,
in fd, flags, func,
and handle.
If an error occurs, the function returns -1.
An error occurs if the received event doesn't
belong to one of the file descriptors attached with
select_attach().
#include <sys/dispatch.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int my_func( select_context_t *ctp,
int fd,
unsigned flags,
void *handle ) {
…
}
int main( int argc, char **argv ) {
dispatch_t *dpp;
dispatch_context_t *ctp;
int fd;
unsigned flag;
void *handle;
select_attr_t *attr;
int (*func)( select_context_t *,
int, unsigned, void * );
if( ( dpp = dispatch_create() ) == NULL ) {
fprintf( stderr, "%s: Unable to allocate \
dispatch handle.\n",argv[0] );
return EXIT_FAILURE;
}
if( argc ≤ 2 || (fd = open( argv[1],
O_RDWR | O_NONBLOCK )) == -1 ) {
exit(0);
}
select_attach( dpp, attr, fd,
SELECT_FLAG_READ | SELECT_FLAG_REARM, &my_func, NULL );
ctp = dispatch_context_alloc( dpp );
…
if( select_query( (select_context_t *)ctp, &fd, &flag,
&func, &handle ) == -1 ) {
fprintf( stderr, "Failed to decode last select event.\n");
return 1;
}
}
For more examples using the dispatch interface, see
dispatch_create(),
message_attach(),
resmgr_attach(), and
thread_pool_create().
QNX Neutrino
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
select_attach(),
select_detach()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/select_query.html on line 204
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/select_query.html on line 204