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

MsgRead(), MsgRead_r()

Read data from a message

Synopsis:

#include <sys/neutrino.h>

int MsgRead( int rcvid, 
             void* msg, 
             int bytes, 
             int offset );

int MsgRead_r( int rcvid, 
               void* msg, 
               int bytes, 
               int offset );

Arguments:

rcvid
The value returned by MsgReceive*() when you received the message.
msg
A pointer to a buffer where the function can store the data.
bytes
The number of bytes that you want to read. These functions don't let you read past the end of the thread's message; they return the number of bytes actually read.
offset
An offset into the thread's send message that indicates where you want to start reading the data.

Library:

libc

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

Description:

The MsgRead() and MsgRead_r() kernel calls read data from a message sent by a thread identified by rcvid. The thread being read from must not have been replied to and will be in the REPLY-blocked state. Any thread in the receiving process is free to read the message.

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

The data transfer occurs immediately and the thread doesn't block. The state of the sending thread doesn't change.

You'll use these functions in these situations:

When you're finished using MsgRead(), you must use MsgReply*() to ready the REPLY-blocked process and complete the message exchange.

Blocking states

None. In the network case, lower priority threads may run.

Native networking

The MsgRead() function has increased latency when it's used to communicate across a network — a message pass is involved from the server to the network manager (at least). Depending on the size of the data transfer, the server's lsm-qnet.so and the client's lsm-qnet.so may need to communicate over the link to read more data bytes from the client.

Returns:

The only difference between the MsgRead() and MsgRead_r() functions is the way they indicate errors:

MsgRead()
The number of bytes read. If an error occurs, -1 is returned and errno is set.
MsgRead_r()
The number of bytes read. This function does NOT set errno. If an error occurs, the negative of a value from the Errors section is returned.

If you try to read past the end of the thread's message, the functions return the number of bytes they were actually able to read.

Errors:

EFAULT
A fault occurred in a server's address space when it tried to access the caller's message buffers.
ESRCH
The thread indicated by rcvid doesn't exist or has had its connection detached.
ESRVRFAULT
A fault occurred when the kernel tried to access the buffers provided.

Classification:

QNX Neutrino

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

See also:

MsgReadv(), MsgReceive(), MsgReceivev(), MsgReply(), MsgReplyv(), MsgWrite(), MsgWritev()

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/msgread.html on line 248

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/msgread.html on line 248