re: winsock multiplexed server using select()
-
I have a VS C++ server app that listens for client tcp connections, maintains them in a table, and when the server app receives a message from an app it is a proxy for the server app sends the message to each tcp connection. There will be no more than five connections and the message rate is less than one per second. Now I need to be able to also read any messages coming in from the clients over the same connection. So on one thread, the main one, I am receiving and forwarding msgs from the app I am proxy for to the clients; on another thread I am listening for any new connections; and now I would like to listen for client input from any of the connected clients on a 3rd thread using select(). I maintain a list of all my active connections. Can anyone provide and example using select() that sketches out how to do this. Thanks
-
I have a VS C++ server app that listens for client tcp connections, maintains them in a table, and when the server app receives a message from an app it is a proxy for the server app sends the message to each tcp connection. There will be no more than five connections and the message rate is less than one per second. Now I need to be able to also read any messages coming in from the clients over the same connection. So on one thread, the main one, I am receiving and forwarding msgs from the app I am proxy for to the clients; on another thread I am listening for any new connections; and now I would like to listen for client input from any of the connected clients on a 3rd thread using select(). I maintain a list of all my active connections. Can anyone provide and example using select() that sketches out how to do this. Thanks
Hi Alan! Here a couple of thoughts... a) where's the difference between "the app" and the "server app", are these different processes? b) you mention incoming sockets are maintained in a "table" later a "list", what kind of data structure is this? c) what do you plan to do with the data from incoming clients, forward it to someone and how (callbacks, IPC, etc)? d) do you have to use select(), well, you probably don't want to mix multi-threading and non-blocking sockets? e) why do you start every new messages with "re:"? Questions over questions :) /Moak