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

PhChannelAttach()

Create or use a QNX channel

Synopsis:

int PhChannelAttach( int channel, 
                     int connection,
                     struct sigevent const *event );

Library:

ph

Description:

Use this function if you want the library to create a QNX channel or use one that you've already created.

The event argument describes how Photon is to notify your application. If your application is using the widget library, pass NULL for event. For more information, see sigevent and ionotify() in the QNX 6 Library Reference.

To create a channel and a connection:

PhChannelAttach( 0, -1, NULL )

To attach a channel chid and create a connection:

PhChannelAttach( chid, -1, NULL )

To attach channel chid and connection coid:

PhChannelAttach( chid, coid, NULL )

name_attach() and PtAppAddInput()

PtAppAddInput() and name_attach() both try to create a channel with _NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT set (see the QNX 6 Library Reference). If your application calls both functions, you need to let Photon use the same channel as name_attach(), by calling PhChannelAttach() first, like this:

PhChannelAttach( chid, -1, NULL );

before calling name_attach() or PtAppAddInput().

If you want to create a separate channel for Photon, it doesn't matter whether you create it and give it to PhChannelAttach() before or after calling name_attach(). But keep in mind that since certain mechanisms in Photon library expect the Photon channel to have the two DISCONNECT flags, they might not work properly if it doesn't. One such mechanism is the detection of broken connections (see PtConnectionClientSetError() and PtConnectionServerSetError()) and anything that relies on it.

Returns:

A channel ID, or -1 on error (errno is set).

Errors:

EBUSY
A channel is already attached and chid is nonzero and differs from the current channel ID, or connection isn't -1 and differs from the currently used connection.
EINVAL
The channel argument is 0, but connection isn't -1.
Other values
ChannelCreate() or ConnectAttach() failed.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PtAppAddInput()

Interprocess Communication chapter of the Photon Programmer's Guide

ionotify(), name_attach(), sigevent in the QNX 6 Library Reference


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