[freetds] connect(2) for UDP

Christos Zoulas christos at zoulas.com
Thu Dec 18 13:35:48 EST 2008


On Dec 18,  1:20pm, jklowden at freetds.org ("James K. Lowden") wrote:
-- Subject: Re: [freetds] connect(2) for UDP

| Christos Zoulas wrote:
| > Always prefer poll over select on systems that have it.
| 
| http://www.unixguide.net/network/socketfaq/2.14.shtml

This is a bit out of date... Most systems have poll() today, and actually
some have also enhanced versions (like NetBSD's pollts or linux's epoll*)
I think I've mentioned why poll is superior to select before, but here it
is again:

1. Expensive because you need do operations on bitmasks [ffs/shifts].
2. Expensive because you need to reset the masks before each call.
3. Non portable behavior for >= 256 fd's. All systems need source
   recompilation; some older systems need kernel recompilation.
4. Non-portable behavior with respect to ERESTART.
5. Non-portable behavior when running out of resources. The only
   way to fix this is using non-blocking-io which is a bit of a pain.
6. Non-portable behavior with respect to "struct timeval *timeout".
   This is non-const, and it was originally intended to return
   the time left. Most implementations did not change "timeout", but  
   one or two did, so it is always good to re-initialize "timeout".  
7. Can only report 3 types of events, read/write/except.

| 
| 	"Someone could write an implementation  of poll() that uses select()"
| 
| http://www.sealiesoftware.com/fakepoll.h
| 
| Perhaps we should add this to replacements and always call poll().  

Sure, that is not a big deal.

christos


More information about the FreeTDS mailing list