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/m/msgreceivev.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/m/msgreceivev.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/m/msgreceivev.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/m/msgreceivev.html on line 8

MsgReceivev(), MsgReceivev_r()

Wait for a message or pulse on a channel

Synopsis:

#include <sys/neutrino.h>

int MsgReceivev( int chid,
                 const iov_t * riov,
                 int rparts,
                 struct _msg_info * info );

int MsgReceivev_r( int chid,
                   const iov_t * riov,
                   int rparts,
                   struct _msg_info * info );

Arguments:

chid
The ID of a channel that you established by calling ChannelCreate().
riov
An array of buffers where the function can store the received data.
rparts
The number of elements in the array.
info
NULL, or a pointer to a _msg_info structure where the function can store additional information about the message.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The MsgReceivev() and MsgReceivev_r() kernel calls wait for a message or pulse to arrive on the channel identified by chid and place the received data in the array of buffers pointed to by riov.

These functions are identical, except in the way they indicate errors; see the Returns section for details.

The number of bytes transferred is the minimum of that specified by both the sender and the receiver. The received data isn't allowed to overflow the receive buffer area provided.


Note: The first buffer of the IOV (input/output vector) must be big enough to contain a pulse. If it isn't, the functions indicate an error of EFAULT.

If a message is waiting on the channel when you call MsgReceivev(), the calling thread won't block, and the message is immediately copied. If a message isn't waiting, the calling thread enters the RECEIVE-blocked state until a message arrives.

If multiple messages are sent to a channel without a thread waiting to receive them, the messages are queued in priority order.


Note: The thread's effective priority might change when it receives a message. For more information, see Priority inheritance and messages in the Interprocess Communication (IPC) chapter of the System Architecture guide.

If you pass a non-NULL pointer for info, the functions store additional information about the message and the thread that sent it in the _msg_info structure that info points to. You can get this information later by calling MsgInfo().

On success, MsgReceivev() and MsgReceivev_r() return:

>0
A message was received; the value returned is a rcvid (receive identifier). You'll use the rcvid with other Msg*() kernel calls to interact with and reply to the sending thread. MsgReceivev() changes the state of the sending thread to REPLY-blocked when the message is received. When you use MsgReply*() to reply to the received message, the sending thread is made ready again. The rcvid encodes the sending thread's ID and a local connection ID.
0
A pulse was received; the IOV's first buffer contains a pulse message of type _pulse. When a pulse is received, the kernel space allocated to hold it is immediately released. The _msg_info structure isn't updated.

Note: Don't reply to a pulse.

Blocking states

State Meaning
STATE_RECEIVE There's no message waiting.

Returns:

The only difference between MsgReceivev() and MsgReceivev_r() is the way they indicate errors. On success, both functions return a positive rcvid if they received a message, or 0 if they received a pulse.

If an error occurs:

Errors:

EFAULT
A fault occurred when the kernel tried to access the buffers provided. Because the OS accesses the sender's buffers only when MsgReceivev() is called, a fault could occur in the sender if the sender's buffers are invalid. If a fault occurs when accessing the sender buffers (only) they'll receive an EFAULT and MsgReceivev() won't unblock.
EINTR
The call was interrupted by a signal.
EOVERFLOW
The sum of the IOV lengths exceeds INT_MAX.
ESRCH
The channel indicated by chid doesn't exist.
ETIMEDOUT
A kernel timeout unblocked the call. See TimerTimeout().

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

ChannelCreate(), _msg_info, MsgInfo(), MsgRead(), MsgReadv(), MsgReceive(), MsgReceivePulse(), MsgReceivePulsev(), MsgReply(), MsgReplyv(), MsgWrite(), MsgWritev(), _pulse, TimerTimeout()

Message Passing chapter of Getting Started with QNX Neutrino


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/m/msgreceivev.html on line 321

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/m/msgreceivev.html on line 321