Hey,
I am trying to turn a K60f120m board, using CW 10.3 and MQX 3.8, into a TCP server. Most of the basics are already running, however, I have trouble detecting clients that disconnect in an unusual way, for example by removing the ethernet cable. MQX just keeps sending and trying to receive data. At the moment I am using RTCS_ping() as a workaround. If a socket fails to respond too often, I shut it down. This is obviously not a viable long-term solution. Isn't there a more elegant way to detect an inactive client? Isn't TCP supposed to realize if it sends a message that doesn't arrive at the remote socket?
Thanks in advance!
Solved! Go to Solution.
At IP level, ARP can be used to find out if a remote peer is connected to the network. Example is in dhcpclnt.c
c:\Freescale\Freescale_MQX_4_0\rtcs\source\tcpip\dhcpclnt.c
two functions DHCPCLNT_probe_address() and DHCPCLNT_verify_address().
First functions sends an ARP_request(). After some time delay you may check ARP table by ARP_is_complete().
ARP_request() and ARP_is_complete() can't be called from an application directly, because they are private functions to RTCS library, but they can be made public in the RTCS build project. Just create some public functions in RTCS library as wrappers around calls to ARP_request() and ARP_is_complete().
For TCP level please read:
https://community.freescale.com/message/317209
means return codes from send() and recv() functions may help.
Hi Projektecarus,
The RTCSUG.pdf in MQX path (C:\Freescale\Freescale_MQX_4_0\doc\rtcs) has the following that might help:
You can start the link status monitoring task (ipcfg_task_create()) to automatically rebind in case of Ethernet cable is re-attached. Another method to handle this monitoring is to call ipcfg_task_poll() periodically in an existing task.
Regards,
David
Hey David,
thanks for your reply. It is not exactly what I am looking for, though. Sorry for not being clear with the initial question, but what I need is a possibility to periodically check if a socket's remote counterpart is still existing and responding, no matter if it has been shutdown correctly, the cabel has been unplugged or something else happened. RTCS_ping achieves this, however, it is not an ideal solution as windows firewall blocks it by default, for example.
Ideally the server should do this whenever it sends a message. Check somehow if the remote socket received it.
Regards!
At IP level, ARP can be used to find out if a remote peer is connected to the network. Example is in dhcpclnt.c
c:\Freescale\Freescale_MQX_4_0\rtcs\source\tcpip\dhcpclnt.c
two functions DHCPCLNT_probe_address() and DHCPCLNT_verify_address().
First functions sends an ARP_request(). After some time delay you may check ARP table by ARP_is_complete().
ARP_request() and ARP_is_complete() can't be called from an application directly, because they are private functions to RTCS library, but they can be made public in the RTCS build project. Just create some public functions in RTCS library as wrappers around calls to ARP_request() and ARP_is_complete().
For TCP level please read:
https://community.freescale.com/message/317209
means return codes from send() and recv() functions may help.