One could create multiple instances of TCPSessions from a common TCPSocket
all at once, and this would have the effect you desire. However, TCPSession is usually best for long duration sessions. Another way to do this might be with a "TCP" based "SocketPort" and a thread service pool.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I would like to use multiple threads accepting on the same socket. This is for a self-written webserver.
I haven't quite figured out how to do this with cc++, is it at all possible?
In pseudo code that would be:
server_socket = new Socket;
fork(); (a few times, to create X servers)
while(1)
{
connection_socket = accept(server_socket);
... do stuff with connection
close(connection_socket);
}
One could create multiple instances of TCPSessions from a common TCPSocket
all at once, and this would have the effect you desire. However, TCPSession is usually best for long duration sessions. Another way to do this might be with a "TCP" based "SocketPort" and a thread service pool.