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/photon/lib_ref/pt/ptappaddinputremote.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/photon/lib_ref/pt/ptappaddinputremote.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/photon/lib_ref/pt/ptappaddinputremote.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/photon/lib_ref/pt/ptappaddinputremote.html on line 8

PtAppAddInputRemote()

Add an input processing function for a remote node

Synopsis:

int PtAppAddInputRemote( PtAppContext_t app_context,
                         int nd,
                         pid_t pid,
                         PtInputCallbackProc_t input_func,
                         void *data );

Arguments:

app_context
The address of the application context, a structure that manages all the data associated with this application. Specify NULL for app_context, so that the default context is used.
nd
The node descriptor for the remote node running the process you want to attach an input processing function to. For more information see Node descriptors in ConnectAttach() in the Neutrino Library Reference.
pid
The process ID you want to attach the input handler to. The input function is executed whenever the application receives a message from process pid on node nd. If pid is negative, it's the ID of a Photon pulse, and nd must be 0.

If you specify a pid of 0, the input function is called for every non-Photon event message that's received, but only if there's no input function that catches messages from the sending pid specifically. If pid is 0, you must specify a nd of 0 as well. Your input handler will get all messages from processes on any node, and all pulses (except those that were already handled and returned Pt_END or Pt_HALT).

input_func
A pointer to the input function to be invoked (see below).
data
A pointer to any extra data you want to pass to the input handler.

Library:

ph

Description:

This routine adds a function to a PtMainLoop() input-event processing chain for a process running on a remote node.


Note: To attach an input handling function to a process on your node, use PtAppAddInput().

The input_func argument points to the input function to be invoked. The function takes this form:

int (*input_func)(void *data, int rcvid,
               void *message, size_t size);

The arguments are:

data
The pointer to the data argument passed to PtAppAddInputRemote().
rcvid
For a message from another process, rcvid is the receive ID. Pass it to MsgReceive() to send a reply (see MsgReceive() in the QNX Neutrino Library Reference). To retrieve the pid of the process and the node descriptor of the machine it's running on, use PtGetRcvidPid().

For a Photon pulse, it's the value from the pulse structure (see _pulse in the QNX Neutrino Library Reference).

message
A pointer to the message sent.
size
The size of the message buffer. If the actual message is longer than the buffer, load the rest of the message by calling MsgRead().

If you application knows the maximum size of a message that can be possibly sent to it, you can use PtResizeEventMsg() to ensure that the buffer is large enough.


Note: Receiving a large Photon event may make the buffer bigger than was established by PtResizeEventMsg().

You can declare the function to be of type PtInputCallbackProcF_t to take advantage of the compiler's type-checking.


Note: If the input function changes the display, it should call PtFlush() to make sure the display is updated.

The input function must return one of the following:

Pt_CONTINUE
The input handler doesn't recognize the message. If there are other input handlers attached to the same process ID, they're called. If there are no input handlers attached specifically to this process ID, or if all input handlers attached specifically to this process ID return Pt_CONTINUE, the library looks for input handlers attached to pid 0. If all the input handlers return Pt_CONTINUE, the library replies to the message with an ENOSYS.
Pt_END
The message has been recognized and processed and the input handler needs to be removed from the list. No other input handlers are called for this message.
Pt_HALT
The message has been recognized and processed but the input handler needs to stay on the list. No other input handlers are called for this message.

name_attach() and PtAppAddInputRemote()

PtAppAddInputRemote() and name_attach() both try to create a channel with _NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT set (see the QNX Neutrino Library Reference). If your application calls both functions, you need to let Photon use the same channel as name_attach(). To do this, call these functions in this order:

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 pointer to a PtInputId_t structure that uniquely identifies the specified input function for the given application context. If an error occurs, the function returns NULL.

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PhChannelAttach(), PtAppAddInput(), PtAppCreatePulse(), PtAppRemoveInput(), PtGetRcvidPidNd(), PtMainLoop(), PtResizeEventMsg()

Interprocess Communication chapter of the Photon Programmer's Guide

_pulse, MsgReceive(), and name_attach() in the QNX Neutrino Library Reference


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/photon/lib_ref/pt/ptappaddinputremote.html on line 290

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/photon/lib_ref/pt/ptappaddinputremote.html on line 290