View topic - Read vs Receive

Read vs Receive

anything that doesn't fit to other groups.

Read vs Receive

Postby rldchua » Fri Dec 12, 2003 1:51 am

After reading the help and documentations, I'm not too clear the differences between read and receive? Are there anyone who can help me?
rldchua
New Member
 
Posts: 7
Joined: Thu Dec 11, 2003 5:48 am

Postby rick » Fri Dec 12, 2003 2:52 pm

Do you mean MsgReceive() and MsgRead()? If so, It may easier to look at these calls in terms of their effects on the states of the sender and receiver.

The MsgReceive() call blocks waiting for some other program to call MsgSend() and send a message. If your program calls MsgReceive(), it changes to a blocked state (RECEIVE) waiting for another program to MsgSend() to it.

After you have called MsgReceive(), you can call MsgRead() if for some reason you didn't read all the message the first time (with MsgReceive()) or if you want to read it again.

An example of why you would do this is if the server (the program calling MsgReceive()) doesn't know which message it will get and the messages are of different sizes. The server would then only call MsgReceive() with a buffer sized to only contain the header. Once the header is received and the server knows the size it needs, it can call MsgRead() and read the rest of the message into the appropriate buffer.

In a lot of situations, you will never use MsgRead(). Basic QNX inter process communication can be handled the MsgSend(), MsgReceive() and MsgReply() calls. All the other related calls are just variations and special cases.

Of couse if you meant some other call instead of MsgRead and MsgReceive, just ignore this. :-)

Rick..
rick
QNX Master
 
Posts: 500
Joined: Wed Nov 13, 2002 3:59 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron