message_connect()

Создать соединение с каналом

Прототип:

#include <sys/iofunc.h>
#include <sys/dispatch.h>
int message_connect( dispatch_t *dpp,
int flags );

Аргументы:

dpp
The dispatch handle, as returned by dispatch_create().
flags
Currently, the following flag is defined in <sys/dispatch.h>:
MSG_FLAG_SIDE_CHANNEL
request the connection ID be returned from a different space. This ID will be greater than any valid file descriptor. Once created there's no difference in the use of the messaging primitives on these IDs.

Библиотека:

libc

Описание:

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


Note: The message_connect() function works only when the dispatch blocking type is receive, i.e. attaches were done for resmgr, message, or select “type” events. If no attaches were done yet, the message_connect() call fails, since dispatch can't determine if receive or sigwait blocking will be used.

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

Идентификатор соединения. Если возникла ошибка функция возвращает -1, код ошибки записывается в errno.

Коды ошибок:

EAGAIN
All kernel connection objects are in use.
EINVAL
Dispatch dpp doesn't have a channel.

Примеры:

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

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

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

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

Предостережения:

Dispatch dpp must block on messages.

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

ConnectAttach(), message_attach()




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