Skip to contentSkip to conversation

Xddp protocol: question of one example

Xenomai Leopold Palomo-Avellaneda 2 participants 4 messages Dec 18, 2013 – Dec 20, 2013

lore
Share & tools
lore
#0 lore raw

Hi,

I'm developing an application that need (as always) interchange data between a realtime part and non-realtime.

Looking on the documentation and surfing on the web I have found interesting for my app the examples of xddp protocol. Some time ago, there was an interesting mail about it [1].

There, the original author ask one thing that I would like to be sure that I understood. On the examples, the realtime thread uses the function recvfrom() to receive data from the non-rt thread.

In the mail, the original author asked about make recvfrom call non-blocking in xddp context, and *Philippe Gerum* answered that MSG_DONTWAIT should be set in flags.

So, my question is that using that flag, some code like this:

/* Read back packets echoed by the regular thread */ ret = recvfrom(s, buf, sizeof(buf), 0, NULL, 0); if(ret <= 0)

    fail("recvfrom");

recvfrom will not be blocked, but it will return 0?

May I understood that if there's data on the sockect recvfrom will return something and if no, it would not be blocked and return something?

Thanks in advance,

Leopold

[1] http://www.xenomai.org/pipermail/xenomai/2010-February/019364.html

Signature · 8 lines
--
Linux User 152692     PGP: 0xF944807E
Catalonia
-------------------------------------
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
#1 lore raw
Quoted 18 lines · Leopold Palomo-Avellaneda

Hi,

I'm developing an application that need (as always) interchange data between a realtime part and non-realtime.

Looking on the documentation and surfing on the web I have found interesting for my app the examples of xddp protocol. Some time ago, there was an interesting mail about it [1].

There, the original author ask one thing that I would like to be sure that I understood. On the examples, the realtime thread uses the function recvfrom() to receive data from the non-rt thread.

In the mail, the original author asked about make recvfrom call non-blocking in xddp context, and *Philippe Gerum* answered that MSG_DONTWAIT should be set in flags.

So, my question is that using that flag, some code like this:

/* Read back packets echoed by the regular thread */ ret = recvfrom(s, buf, sizeof(buf), 0, NULL, 0); if(ret <= 0)

Quoted 7 lines
     fail("recvfrom");

recvfrom will not be blocked, but it will return 0?

May I understood that if there's data on the sockect recvfrom will return something and if no, it would not be blocked and return something?

Standard behavior when no data present: immediate return with ret = -1, errno = EWOULDBLOCK/EAGAIN.

Signature · 1 line
Philippe.
#2 lore raw

A Divendres, 20 de desembre de 2013, Philippe Gerum va escriure:

Quoted 4 lines · Leopold Palomo-Avellaneda
Quoted 3 lines

Hi,

I'm developing an application that need (as always) interchange data

between a realtime part and non-realtime.

Quoted 2 lines
Quoted 2 lines

Looking on the documentation and surfing on the web I have found

interesting for my app the examples of xddp protocol. Some time ago, there was an interesting mail about it [1].

Quoted 2 lines
Quoted 2 lines

There, the original author ask one thing that I would like to be sure that

I understood. On the examples, the realtime thread uses the function recvfrom() to receive data from the non-rt thread.

Quoted 13 lines
Quoted 13 lines

In the mail, the original author asked about make recvfrom call non-blocking in xddp context, and *Philippe Gerum* answered that MSG_DONTWAIT should be set in flags.

So, my question is that using that flag, some code like this:

/* Read back packets echoed by the regular thread */ ret = recvfrom(s, buf, sizeof(buf), 0, NULL, 0); if(ret <= 0)

     fail("recvfrom");
Quoted 8 lines
Quoted 5 lines

recvfrom will not be blocked, but it will return 0?

May I understood that if there's data on the sockect recvfrom will return something and if no, it would not be blocked and return something?

Standard behavior when no data present: immediate return with ret = -1, errno = EWOULDBLOCK/EAGAIN.

Ok,

if you are writing some data (some bytes) in the socket, can I trust that recvfrom will return -1 until ALL data is transferred?

Regards,

Leopold

Signature · 10 lines
--
Linux User 152692
Catalonia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20131220/e7764858/attachment.sig>
#3 lore raw
Quoted 33 lines · Leopold Palomo-Avellaneda

A Divendres, 20 de desembre de 2013, Philippe Gerum va escriure:

Quoted 4 lines · Leopold Palomo-Avellaneda
Quoted 3 lines

Hi,

I'm developing an application that need (as always) interchange data

between a realtime part and non-realtime.

Quoted 2 lines
Quoted 2 lines

Looking on the documentation and surfing on the web I have found

interesting for my app the examples of xddp protocol. Some time ago, there was an interesting mail about it [1].

Quoted 2 lines
Quoted 2 lines

There, the original author ask one thing that I would like to be sure that

I understood. On the examples, the realtime thread uses the function recvfrom() to receive data from the non-rt thread.

Quoted 19 lines
Quoted 18 lines

In the mail, the original author asked about make recvfrom call non-blocking in xddp context, and *Philippe Gerum* answered that MSG_DONTWAIT should be set in flags.

So, my question is that using that flag, some code like this:

/* Read back packets echoed by the regular thread */ ret = recvfrom(s, buf, sizeof(buf), 0, NULL, 0); if(ret <= 0)

      fail("recvfrom");

recvfrom will not be blocked, but it will return 0?

May I understood that if there's data on the sockect recvfrom will return something and if no, it would not be blocked and return something?

Quoted 8 lines
Quoted 2 lines

Standard behavior when no data present: immediate return with ret = -1, errno = EWOULDBLOCK/EAGAIN.

Ok,

if you are writing some data (some bytes) in the socket, can I trust that recvfrom will return -1 until ALL data is transferred?

Yes, guaranteed for all nrt -> rt transfers. This also applies the other way, unless MSG_MORE is given to sendmsg() with streaming mode enabled for the socket, and the message spans multiple output buffers (see setsockopt(XDDP_BUFSZ) for enabling streaming mode).

Signature · 1 line
Philippe.