MsgSend and MsgSendv -- has different results on server side

Hi!

eg:
server:
char buf[50];
struct _msg_info msg_info;
rcvid = MsgReceive(chid, buf, 40, &msg_info);
printf (“srclen:%d msglen:%d\n”, msg_info.srcmsglen, msg_info.msglen);

client-MsgSend:
char buf[50];
MsgSend(coid, buf, 45, NULL, 0);

server prints:
srclen:45 msglen:40

and if:
client-MsgSendv:
char buf[50];
iov_t iov[2];
SETIOV(iov+0, buf, 40);
SETIOV(iov+1, buf+40, 5);
// send 45 bytes too !!!
MsgSendv(coid, iov, 2, NULL, 0);


BUT in last case server prints:
srclen:40 msglen:40

WHY THOSE DIFFERENTES IN
msg_info.srcmsglen
???


Respectfully Yours
vasa

See the _NTO_CHF_SENDER_LEN flag to ChannelCreate.

-seanb

vasa <vv40in@newmail.ru> wrote:

Hi!

eg:
server:
char buf[50];
struct _msg_info msg_info;
rcvid = MsgReceive(chid, buf, 40, &msg_info);
printf (“srclen:%d msglen:%d\n”, msg_info.srcmsglen, msg_info.msglen);

client-MsgSend:
char buf[50];
MsgSend(coid, buf, 45, NULL, 0);

server prints:
srclen:45 msglen:40

and if:
client-MsgSendv:
char buf[50];
iov_t iov[2];
SETIOV(iov+0, buf, 40);
SETIOV(iov+1, buf+40, 5);
// send 45 bytes too !!!
MsgSendv(coid, iov, 2, NULL, 0);



BUT in last case server prints:
srclen:40 msglen:40

WHY THOSE DIFFERENTES IN
msg_info.srcmsglen
???


Respectfully Yours
vasa

I think he was asking why is there a difference between MsgSend
and MsgSendv, rather than why is there a difference between srclen
and msglen.

I thought that MsgSend == MsgSendv in terms of behaviour, except
that one takes a linear buffer and one takes an IOV. (I don’t
have access to the docs here, so in case you are right, and
_NTO_CHF_SENDER_LEN really does do something magically different
between MsgSend and MsgSendv on the client side, I apologize in
advance :slight_smile:)

Cheers,
-RK

Sean Boudreau <seanb@node25.ott.qnx.com> wrote:

See the _NTO_CHF_SENDER_LEN flag to ChannelCreate.

-seanb

vasa <> vv40in@newmail.ru> > wrote:
Hi!

eg:
server:
char buf[50];
struct _msg_info msg_info;
rcvid = MsgReceive(chid, buf, 40, &msg_info);
printf (“srclen:%d msglen:%d\n”, msg_info.srcmsglen, msg_info.msglen);

client-MsgSend:
char buf[50];
MsgSend(coid, buf, 45, NULL, 0);

server prints:
srclen:45 msglen:40

and if:
client-MsgSendv:
char buf[50];
iov_t iov[2];
SETIOV(iov+0, buf, 40);
SETIOV(iov+1, buf+40, 5);
// send 45 bytes too !!!
MsgSendv(coid, iov, 2, NULL, 0);



BUT in last case server prints:
srclen:40 msglen:40

WHY THOSE DIFFERENTES IN
msg_info.srcmsglen
???


Respectfully Yours
vasa



Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Robert Krten <nospam83@parse.com> wrote:

I think he was asking why is there a difference between MsgSend
and MsgSendv, rather than why is there a difference between srclen
and msglen.

I thought that MsgSend == MsgSendv in terms of behaviour, except
that one takes a linear buffer and one takes an IOV. (I don’t
have access to the docs here, so in case you are right, and
_NTO_CHF_SENDER_LEN really does do something magically different
between MsgSend and MsgSendv on the client side, I apologize in
advance > :slight_smile:> )

_NTO_CHF_SENDER_LEN does something different. In fact, unless you
set this flag, srcmsglen does not have to have a meaningful value.
Or, to put it another way, unless you set this flag, srcmsglen is
undefined – it could be anything.

Basically, setting this flag asks the kernel to sum the iov_len for
all the (possibly multiple) parts of a multi-part message – otherwise
the kernel takes the shortcut of not doing the summation.

Apparently it fills in the value of the first part if you don’t
specify it – this will actually work fine for the MsgSend() case,
as then there is only one part, but not for a multi-part message.
Of course, you shouldn’t depend on this behaviour – if you want
this field to be valid, set the flag in your ChannelCreate() call.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

David Gibbs <dagibbs@qnx.com> wrote:

Robert Krten <> nospam83@parse.com> > wrote:
I think he was asking why is there a difference between MsgSend
and MsgSendv, rather than why is there a difference between srclen
and msglen.

I thought that MsgSend == MsgSendv in terms of behaviour, except
that one takes a linear buffer and one takes an IOV. (I don’t
have access to the docs here, so in case you are right, and
_NTO_CHF_SENDER_LEN really does do something magically different
between MsgSend and MsgSendv on the client side, I apologize in
advance > :slight_smile:> )

_NTO_CHF_SENDER_LEN does something different. In fact, unless you
set this flag, srcmsglen does not have to have a meaningful value.
Or, to put it another way, unless you set this flag, srcmsglen is
undefined – it could be anything.

Basically, setting this flag asks the kernel to sum the iov_len for
all the (possibly multiple) parts of a multi-part message – otherwise
the kernel takes the shortcut of not doing the summation.

Apparently it fills in the value of the first part if you don’t
specify it – this will actually work fine for the MsgSend() case,
as then there is only one part, but not for a multi-part message.
Of course, you shouldn’t depend on this behaviour – if you want
this field to be valid, set the flag in your ChannelCreate() call.

Well, that’s it, I give up my product support hat; I’m 0 for 2 today :slight_smile: :slight_smile:

Thanks for clearing that up Dave!

Cheers,
-RK

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Robert Krten <nospam83@parse.com> wrote:

Well, that’s it, I give up my product support hat; I’m 0 for 2 today > :slight_smile: > > :slight_smile:

Thanks for clearing that up Dave!

My single sentence wasn’t sufficient? :slight_smile:

-seanb

Sean Boudreau <seanb@node25.ott.qnx.com> wrote:

Robert Krten <> nospam83@parse.com> > wrote:

Well, that’s it, I give up my product support hat; I’m 0 for 2 today > :slight_smile: > > :slight_smile:

Thanks for clearing that up Dave!

My single sentence wasn’t sufficient? > :slight_smile:

Cryptic. :slight_smile:

-RK

Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.