I have a driver that needs to distribute data to 42 receivers. As that amount is variable and creating a driver with 42 fixed ports is too much, so the choice has been made to work through a multi-threaded serial timer. Every second it will be sending data.
This is working good to distribute the data, however there is one problem: every time data gets sent it's opening and closing a new TCP socket. This means opening 42 sockets and Windows by default reserves such a socket for 4 minutes so we're running out of ports.
Is there a way for a multi-threaded serial timer to keep the socket open and re-use this? Kind of link an opened socket to a row in a table over which the multi-threaded timer iterates.
The driver does not wait for a response (only sends commands), could this be a cause and could the solution be to let the receiving side send back a response?
Could a multi-threaded http timer be a solution with keep alive defined?
Other alternative that I can think about, but like to avoid, would be to open the TCP socket in the QAction and leave them open there. I would like to avoid going through SLScripting and use the core software to handle the connection through SLPort instead.
The only solution currently possible would be to reduce the amount of time the socket keeps open in windows. This can be changed in Windows Registry.
More information can be found on this page:
Appendix A: TCP/IP Configuration Parameters | Microsoft Docs