ported to FreeRTOS

This commit is contained in:
Araq 2020-11-13 17:03:07 +01:00
commit 9f566881f1
2 changed files with 22 additions and 11 deletions

View file

@ -308,9 +308,18 @@ proc processClient(server: AsyncHttpServer, client: AsyncSocket, address: string
)
if not retry: break
const
nimMaxDescriptorsFallback* {.intdefine.} = 16_000 ## fallback value for \
## when `maxDescriptors` is not available.
## This can be set on the command line during compilation
## via `-d:nimMaxDescriptorsFallback=N`
proc listen*(server: AsyncHttpServer; port: Port; address = "") =
## Listen to the given port and address.
server.maxFDs = maxDescriptors()
when declared(maxDescriptors):
server.maxFDs = try: maxDescriptors() except: nimMaxDescriptorsFallback
else:
server.maxFDs = nimMaxDescriptorsFallback
server.socket = newAsyncSocket()
if server.reuseAddr:
server.socket.setSockOpt(OptReuseAddr, true)