From: Per Oberg <pero@wolfram.com>
To: xenomai <xenomai@xenomai.org>
Subject: Re: Is it possible to tell whether a network socket is/will be a real time socket or a regular socket runtime?
Date: Thu, 1 Oct 2020 06:19:39 -0500 (CDT) [thread overview]
Message-ID: <1641460906.3136541.1601551179008.JavaMail.zimbra@wolfram.com> (raw)
In-Reply-To: <180268575.3119360.1601538086890.JavaMail.zimbra@wolfram.com>
----- Den 1 okt 2020, på kl 9:41, xenomai <xenomai@xenomai.org> skrev:
> Hi list
> Is there a way that I can tell if a network socket is a real time socket or a
> regular socket runtime ?
> Usually I always know beforehand whether something is going to be a real time
> socket or a std posix socket. Now it will depend on the host-address.
> I have this posix-skin application that can be both real time and non real time
> depending on available network hardware. Because of the differences between
> RTNet and regular posix net implementation i sometimes have to choose between
> setsockopt/ioctl when setting the properties. Therefore I need to handle a few
> lines of code differently depending on the situation.
> This brings up another issue I have been struggling with for the posix-skin.
> When, in this snippet of code, is it decided whether __std or __cobolt functions
> are executed ?
> Is it run-time or compile time ? If runtime, is it during the connect or during
> the sendto ?
I ended up doing an ugly hack using
getifaddrs(&ifaddr) and matching for the IP/Netmask i am connecting to. Then I do
__STD(socket()) or __COBALT(socket()) depending on the result. After that i use regular connect / sendto / recvfrom without macros.
So: If it's an RT socket already after the call to "socket" the wrapper will know that its a RT socket and use the correct functions hereafter ??
> serv_addr.sin_family = AF_INET;
> serv_addr.sin_addr.s_addr = inet_addr(host_name);
> serv_addr.sin_port = htons( portno );
> sockfd = socket(AF_INET, SOCK_DGRAM,0);
> connect( sockfd, ( struct sockaddr * ) &serv_addr, sizeof( serv_addr))
> sendto(sockfd, (char*) &packet, sizeof( packetType ), MSG_DONTWAIT, NULL,
> sizeof( serv_addr ));
> Regards
> Per Öberg
Regards
Per Öberg
prev parent reply other threads:[~2020-10-01 11:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-01 7:41 Is it possible to tell whether a network socket is/will be a real time socket or a regular socket runtime? Per Oberg
2020-10-01 11:19 ` Per Oberg [this message]
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=1641460906.3136541.1601551179008.JavaMail.zimbra@wolfram.com \
--to=pero@wolfram.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.