server listening to multiple sockets? select() function?

Showing results for 
Show  only  | Search instead for 
Did you mean: 

server listening to multiple sockets? select() function?

Contributor IV
I'm trying to implement a TCP socket server that can listen to multiple connections, but all the MQX examples seem to show the server listening to a single connection at a time. Is there a way to structure the code so it's listening for both incoming connection requests and incoming data from already connected sockets? In Linux, I used the select statement, and had it checking both. Should these be separate tasks under MQX? One listening for new connections and spawning new tasks for each socket as it connects? Polling? (Yikes!) John
Labels (1)
Tags (1)
0 Kudos
1 Reply

Contributor V

I guess you can do that in one task by creating one socket per port and use RTCS_selectall() to wait for events on at least one socket and then process them with accept() or recv().

See RTCS User's Guide in BSP source tree : doc/rtcs/MQXRTCSUG.pdf (also downloadable form Freescale's web)

There's some sample code in the doc.