Server with an undefined number of sockets

dear all,
I would like to write a server application using ROOT sockets.
What I would like to do is to have a server waiting for an undefined number of connection which is able to communicate with the currently active sockets.

Reading the user’s guide I clearly understood how to use TMonitor object in order to select and communicate with a socket sending data to the server. My problem is that I do not understand how to select simultaneously sockets which want to send data and sockets which want to connect the server.

If I do in this way

TSocketServer server(myPort);
TMonitor monitor;
monitor.Add(server.Accept());
monitor.Add(server.Accept());
TSocket *socket;
while(1){
socket = monitor.Select();
… (more code)
}

the server waits for two connections and then it starts its main loop.

What I would like is something like this

TSocketServer server(myPort);
TMonitor monitor;
TSocket *socket
while(1){
socket = [a select statement which looks both for new connections and already
active sokets sending data… somehow like returning the socket pointer
if the socket wants to communicate and returning NULL if the socket
wants to connect ];
if (isANewSocket)
monitor.Add(server.Accept());
else{
… (more code)
}
}

actually I have no idea about how to manage this using ROOT sockets… I did something like this using LINUX sockets (using select), but I would prefer to use ROOT socket support if it is possible.

many thanks
roberto

mmmhhh…

probably I found the solution…

TServerSocket server(myPort);
TMonitor monitor;
monitor.Add(&server);
TSocket *socet;
while(1){
socket = monitor.Select();
if (!socket->GetInetAddress().IsValid())
monitor.Add(server.Accept());
else{
… more code
}
}

does it sound reasonable for you?