The maximum number of file descriptors is a constant value provided by
the preprocessor definition OPEN_MAX.
On 2/16/2023 5:44 PM, KIKUCHI Takeyoshi wrote:
currently porting the Nim language to NuttX.
(It has been merged into the Nim devel branch)
When using select/epoll, it is necessary to determine the maximum
value of file descriptor in order to assign a structure to store the
fd to be waited in advance.
It is used in this way.
---------
proc newSelector*[T](): Selector[T] =
# Retrieve the maximum fd count (for current OS) via getrlimit()
var maxFD = maxDescriptors() <---
# Start with a reasonable size, checkFd() will grow this on demand
const numFD = 1024
...
for i in 0 ... < numFD:
result.fds[i].ident = InvalidIdent
---------
(Now I realize that numFD also needs to be switched for NuttX...)
Since the available memory capacity varies from device to device,
Is there any way to find the best value for each build config?
Porting to FreeRTOS in the Nim language uses the maximum number of
sockets available, set by the user at build time.
---------
var FD_MAX* {.importc: "CONFIG_LWIP_MAX_SOCKETS", header:
"<lwipopts.h>".} : cint
---------
best regards,
KIKUCHI Takeyoshi