Five Pitfalls of Linux Sockets Programming (developerWorks)
Posted Sep 22, 2005 10:45 UTC (Thu) by
RobSeace (subscriber, #4435)
In reply to:
Five Pitfalls of Linux Sockets Programming (developerWorks) by ratz
Parent article:
Five Pitfalls of Linux Sockets Programming (developerWorks)
> I don't have many examples ready, but consider a simple thing like
> the backlog queue size (settable in the listen() call for example) and
> mechansim. The implementation differs on a lot of Unices and its derivates.
Yes, and that's sort of what I was saying: Linux is no more different in
this area than any other Unix-like system is... There is no "standard"
interpretation of what the listen() backlog truly means, and so every
Unix-like system does things a little bit different... But, this is to
be expected, and no one should really assume one behavior or another,
since it's a well-known sockets portability issue... (In fact, there's
rarely any use for passing anything other than SOMAXCONN as the listen()
backlog, and letting the system give you however much it can in whatever
way it wants to... Though, I'm an admin over at The Unix Socket FAQ Forum,
and it seems every so often, someone will stop by complaining that a
listen() backlog of 1 isn't working like they thought it should, and is
allowing more than 1 client to queue up... I have no idea why people try
to do such a strange thing in the first place, but it seems a fairly
common desire, I guess... But, it's their expectations that are wrong,
not any particular behavior of listen()... Though, this is another area
where man pages don't exactly help the situation much, since they generally
all say something like "The backlog parameter defines the maximum length
the queue of pending connections may grow to.", without mentioning any of
the controversy over just WTF that actually means... ;-) Is it the completed
but unaccepted queue, or the incomplete connection queue, or the sum of both
of them? Is the given backlog taken literally as the max, or is it bounded
by some internal limits, or is it modified by some internal calculation to
increase its value above what you actually specified? Who knows! ;-))
(
Log in to post comments)