server listening to multiple sockets? select() function?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

server listening to multiple sockets? select() function?

828件の閲覧回数
jpa
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
ラベル(1)
タグ(1)
0 件の賞賛
1 返信

335件の閲覧回数
trailman
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.