All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Laurent LEQUIEVRE <laurent.lequievre@gmail.com>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking
Date: Fri, 17 Jun 2016 12:21:22 +0200	[thread overview]
Message-ID: <20160617102122.GL32532@hermes.click-hack.org> (raw)
In-Reply-To: <20160617100728.GK32532@hermes.click-hack.org>

On Fri, Jun 17, 2016 at 12:07:28PM +0200, Gilles Chanteperdrix wrote:
> On Fri, Jun 17, 2016 at 11:55:20AM +0200, Laurent LEQUIEVRE wrote:
> > Hello,
> > 
> > I installed xenomai 3.0.2 and try to test some RTnet features needed for 
> > the communication with my Kuka robot arm.
> > 
> > I specify that I want to work with the skin posix only.
> > 
> > I need to create a UDP socket with a timeout on the 'recvfrom' function 
> > (Non blocking recvfrom).
> > 
> > I tested this first code :
> > 
> > int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> > bind(udp_socket, ...)
> > struct timeval timeout;
> > timeout.tv_sec = 1;
> > timeout.tv_usec = 0;
> > 
> > setsockopt(udp_socket, SOL_SOCKET, SOCKET_SO_RCVTIMEO, &timeout, 
> > sizeof(timeout));
> > --> this function return -1, errno=92, Protocol not available ???
> 
> This socket option is not implemented in RTnet sockets. You can use
> the RTNET_RTIOC_TIMEOUT ioctl instead.
> 
> 
> > ....
> > recvfrom(udp_socket, ....) --> blocked ??
> > 
> > I tested this second code :
> > 
> > int udp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
> > bind(udp_socket, ...)
> > fcntl(udp_socket, F_SETFL, O_NONBLOCK);
> > --> this function return 0
> > ....
> > recvfrom(udp_socket, ....) --> blocked ??
> 
> RTnet UDP recvfrom does not check the O_NONBLOCK flag, you can use
> recvmsg with MSG_DONTWAIT instead.

You can also use the MSG_DONTWAIT flag in recvfrom.

-- 
					    Gilles.
https://click-hack.org


  reply	other threads:[~2016-06-17 10:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17  9:55 [Xenomai] need help to Xenomai Cobalt RTnet socket UDP recvfrom non blocking Laurent LEQUIEVRE
2016-06-17 10:07 ` Gilles Chanteperdrix
2016-06-17 10:21   ` Gilles Chanteperdrix [this message]
2016-06-17 11:28   ` Laurent LEQUIEVRE
2016-06-17 13:04     ` laurent LEQUIEVRE
2016-06-19  6:45       ` Gilles Chanteperdrix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160617102122.GL32532@hermes.click-hack.org \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=laurent.lequievre@gmail.com \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.