On onsdag, jan 22, 2003, at 22:12 Europe/Stockholm, Alberto Alonso wrote:
accept is safe to be called from multiple threads/processes at the same time, the OS guarantees that only one thread will get the accept, this is infact the recommended approach since you don't have one thread blocking the rest (this is how apache does it) However on older operating systems you have a problem called "Thundering Herd", where all threads are woken up and then put to sleep again except the one that gets it, to avoid that you can use a lock() to control access to the accept socket.That's exactly my point. The underlying system seems to make it work.I have not trying to run the code that was posted, that is why I was trying to get more info on it. I think that the thread handling the accepts is the thread that binded the socket. On the other hand all threads may have the correct socket reference, which brings up the question as to how the OS signals that the socket is already on an accept state, does it wait for it to be released? Alberto
so bind the socket, start the threads, accept in each separate thread
Arthur
