select_attach()

Подключить файловый дескриптор к диспетчеру

Прототип:

#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 );

Аргументы:

dpp
The dispatch handle, as returned by dispatch_create(), that you want to attach to a file descriptor.
attr
A pointer to a select_attr_t structure.
fd
The file descriptor that you want to attach to the dispatch handle.
flags
Flags that specify the events that you're interested in.
func
The function that you want to call when the file descriptor unblocks.
handle
A pointer to arbitrary data that you want to pass to func.

Библиотека:

libc

Описание:

The function select_attach() attaches the file descriptor fd to the dispatch handle dpp and selects флаги events. When fd “unblocks”, func is called with handle.

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 depends on the resource manager.
SELECT_FLAG_READ
There's input data available. The amount of data available defaults to 1. For a character device such as a serial port, this is a character. For a POSIX message queue, it's a message. Each resource manager selects 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 depends on the resource manager. 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
Register 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_DISCONNECT flag. In this case, fd is ignored.)

Function

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
The type of event that occurred. The possible flags are:
SELECT_FLAG_EXCEPT
SELECT_FLAG_READ
SELECT_FLAG_WRITE
handle
The handle passed to select_attach().

Возвращаемое значение:

0
Успешное завершение.
-1
Возникла ошибка. Код ошибки записан в errno.

Коды ошибок:

EINVAL
Invalid argument.
ENOMEM
Insufficient memory was available.

Примеры:

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().

Классификация:

ЗОСРВ «Нейтрино»

Точка остановки потока
Да
Обработчик прерываний
Нет
Обработчик сигналов
Нет
В потоке
Да

Тематические ссылки:

select_attr_t, select_detach(), select_query()




Предыдущий раздел: Описание API системной библиотеки