Hello.
I am adding TCP-Keepalives to an existing project using BSD sockets. It seems that setting the TCP connection/idle timeout is only possible for TCP API Sockets using netTCP_SetOption() but not for BSD Sockets. (Other than the default setting in Net_Config_TCP.h.)
Since BSD Sockets are implemented on top of the UDP and TCP Socket APIs, (how) can I get the underlying native TCP connection socket from a BSD connection socket?
From Can I use both TCP native sockets and BSD sockets? I glean that I should not use "mixed" native TCP and BSD API functions on the same connection. So I would just like to set the timeout and then forget about the TCP native Socket. - Would that be fine?
That's the code I'm using to activate TCP Keep-Alives. That works but it seems I can not change the Timeout of the Keep-Alives at runtime using BSD sockets. In other words, the Keep-Alives are sent in an interval of the timeout specified in Net_Config_TCP.h.
It seems using the native TCP sockets API you can change this interval per existing connection using netTCP_SetOption() with netTCP_OptionTimeout as the option.
Apparently this is not possible with BSD sockets. But switching to native TCP sockets would be quite a lot of work in that project. A quick solution to the dilemma would be to use some way to get the underlying TCP socket (since BSD sockets are implemented on top of native TCP and native UDP sockets) and set the interval with it.
Haven't found a way to do that, so that's why I'm asking.
For middleware versions up to 7.17.1, you can access it with this code:
#include "rl_net_lib.h" int32_t bsd_socket; uint8_t tcp_socket; tcp_socket = net_bsd_config.Scb[bsd_socket-1].Socket;
Works fine with Middleware 7.12.0.
Thank you very much!