Menu

multiple threads accepting on the same socket

Anonymous
2000-08-14
2000-08-30
  • Anonymous

    Anonymous - 2000-08-14

    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);
    }

     
    • David Sugar

      David Sugar - 2000-08-30

      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.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.