All of lore.kernel.org
 help / color / mirror / Atom feed
* Is it possible to tell whether a network socket is/will be a real time socket or a regular socket runtime?
@ 2020-10-01  7:41 Per Oberg
  2020-10-01 11:19 ` Per Oberg
  0 siblings, 1 reply; 2+ messages in thread
From: Per Oberg @ 2020-10-01  7:41 UTC (permalink / raw)
  To: xenomai

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 ? 

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 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is it possible to tell whether a network socket is/will be a real time socket or a regular socket runtime?
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Per Oberg @ 2020-10-01 11:19 UTC (permalink / raw)
  To: xenomai

----- 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-01 11:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.