Forum Topic - MsgSendvs Returning 34: (6 Items)
   
MsgSendvs Returning 34  
My team uses QNX version 7.1.0 and we're having trouble using the MsgSendvs system call. We have identified a case in 
which MsgSendvs returns 34 but according to our understanding of the documentation that is not possible.

The documentation says MsgSendvs should return -1 on error or the status of MsgReply, which should only be EOK or -1.

We need help understanding documentation. How's it possible that MsgReply is returning a value of 34? What is meant by 
the "status of MsgReply"?

Docs:
https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/m/msgsendvs.html
https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/m/msgreply.html
Re: MsgSendvs Returning 34  
Forgot to add that MsgSendvs set errno to 2 "No such file or directory"
Re: MsgSendvs Returning 34  
1. MsgSend*() (in all its variants) returns the value passed by MsgReply*() in its status argument. The semantics of 
this value is whatever the replying server says they are. For example, a file system reply to a read request will set 
the status to the number of bytes returned in the reply.
2. A return value of -1 for the MsgSend*() (non _r variants) or a negative value (for the _r variant) indicate an error.
 Unfortunately QNX does not provide a mechanism to distinguish between errors returned by the call itself (e.g., EBADF 
because the connection is not established) and errors returned by the server via MsgError(). A truly misbehaving server 
can also reply with a status that looks like an error.
3. errno is only valid if a non _r variant is used AND MsgSend*() returned -1. Otherwise its value is stale from some 
previous call.

--Elad
Re: MsgSendvs Returning 34  
What exactly do you mean by “returns the value passed by MsgReply*() in its status argument”? We don’t understand 
what this means.
What return value should we check for MsgSendvs()?
Should we check if MsgSendvs() != 0 and then examine errno in that case? 
We thought based on the documentation that we could do: 

if( MsgSendvs() == -1 ) {
	// check errno and handle error
}

Is that not correct?
Re: MsgSendvs Returning 34  
This is basic message passing in QNX, which I sure hope is covered by the documentation.

Client:

rc = MsgSend(coid, &msg, sizeof(msg), &reply_buf, sizeof(reply_buf));

Server:

rcvid = MsgReceive(chid, &buf, sizeof(buf), &info);
// Do work
MsgReply(rcvid, status, &reply, sizeof(reply));

Client now returns with the value of "status" in "rc", a copy of the server's reply in "reply_buf". 

An error is returned if one of the following occurs:

1. MsgSend() fails to send the message to the server
2. The server indicates an error by using MsgError() instead of MsgReply()
3. The server fails on its MsgReply() call

--Elad
Re: MsgSendvs Returning 34  
Walter, as Elad is pointing out, the server can send two things back when replying.
MsgReply(rcvid, status, &reply_msg, sizeof(reply_msg)
In the above, that's the status and the reply_msg. The status sets the return value for MsgSendvs(), provided the MsgSendvs() doesn't fail.
So for...
rc = MsgSendvs(...)
rc seems to be 34 in your case. i.e., the server is doing something like...
MsgReply(rcvid, 34, &reply_msg, sizeof(reply_msg)
To find out what the server is expected to send back, what 34 represents, you need to check the server code or check with whomever wrote the server code or often there's a common header file that both the client and server include that describes the message protocol.
We recommend that the server use a value >= 0 for the status, negative values can be confusing for the client.