Forum Discussion
Netx Duo Question - NX_TCP_SOCKET and BSD fd_sets Functionality
Hi Wayne,
You’re right - the Duo/NetX stack doesn’t provide a direct equivalent to fd_set/select() like you’d see in a BSD socket environment. With NX_TCP_SOCKET you’re mostly working with callback-driven events and explicit status checking rather than multiplexing across a set of sockets.
The usual approach is:
Use NetX Duo socket callbacks (nx_tcp_socket_receive_notify, nx_tcp_socket_disconnect_complete_notify, etc.) to get notified when data arrives or the state changes.
Maintain your own lightweight state machine if you need to track multiple sockets and their readiness at once.
For WebSockets/TLS specifically, you’ll typically wrap the NX_SECURE_TLS_SESSION over an NX_TCP_SOCKET and keep the socket open across multiple sends/receives.
if you’re porting code that depends heavily on select()/fd_set, you’ll likely need to build a small abstraction layer that normalizes the NetX Duo callbacks into a poll-like API. We had to do some equal thing in a project at Modsen, where we migrated a legacy BSD-sockets application onto NetX Duo. Our solution was to implement a “socket manager” task that monitored callbacks and queued readiness events, which the rest of the app could consume in a select()-like fashion.
So short answer: there’s no built-in fd_set, but with callbacks + a small abstraction you can get equivalent behavior.
Hope it will be useful!