Martin, Wilhelm, On 14 Jan 2011, at 20:31, [email protected] wrote:
> "Sven Van Caekenberghe"<[email protected]> wrote: >> Each #acceptWaitTimeout seconds, 'Wait for accept timed out' is printed on >> the log and another accept/wait starts. This looping improves liveliness and >> responsiveness to other events. > > Given that accept is generally done on the server side, usually in a > background process, I have to say I'd be inclined to side with Wilhelm on > this one. I don't see much that the server can do than go back into another > accept loop. You can't predict how long will it take for the next client to > connect, so a timeout isn't a sign of an issue. So I don't see much use for > timeout on accept. > > I'm not quite sure what you mean by "improving liveliness". If the > implementation needs to get out of accept to let other processes respond to > events, then I wouldn't call that a feature. But these are really more > philosophical points. In practice, wrapping a loop around an accept timeout > isn't a big deal either, as long as it works as needed. On 14 Jan 2011, at 20:45, Schwab,Wilhelm K wrote: > Sven, > > Thanks for the code! > > The fact that I have to decide what constitutes an "infinite" delay seems > wrong to me. It should just do what I tell it and either calmly wait for an > event to let the code move forward (assuming that only the calling thread is > blocked). One example: if I know I typed an incorrect address, then any time > is wasted. If it's correct and the connection is slow (I downloaded a pdf of > a paper earlier this week, and it was miserably slow but worked fine), I > probably want the code to keep running without trying to think for itself. > > > "This looping improves liveliness and responsiveness to other events." > > Why does looping on things that should be blocking until events arrive > improve response to other events? This seems like a bailing wire solution to > the problem. Of course it would be better if there was an #waitForAccept variant that waited forever. The fact that you keep looping can be handy to do periodic tasks like cleanups without starting a new thread. In Java you can set the timeout of a ServerSocket and the accept will fall through as well, it is just an option. Sven
