Hi wein,
I also want to limit the number of incoming connections to a TCP service to the number of tasks servicing it.
The reason is that every extra connection waiting to be serviced (accepted) consumes some memory for nothing (as this kind of connections is hanging till another is closed), and can lead to a run out of memory in case of several incomming connections.
So I also want to refuse them with a "connection refused" (for example).
I first tried to set the backlog (second) parameter of listen() (socket specific value), but I discovered it was unused by MQX
I had a look to rtcs/source/tcpip/tcp.c and found RTCSCFG_TCP_MAX_CONNECTIONS.
I tried to set it to 3 (global count for all services); this was OK till I found out that this also applied to outcoming connections. So if my MQX board has 3 open connections as a client to a server, no client can connect to my MQX board.
I also had a look to memory polls to set a specific and limited memory pool for RTCS memory allocations; however the memory allocated even if not fully used can not be used for other purposes.
So I still searching for a solution but don't have enough time to work on it right now.
Probably the best thing would be to implement the backlock parameter of listen() to have a per socket setting.
Please let me know if you find a solution to this problem.