I think we should merge this, or at least a similar API. Any objections? Arne
On 08/28/14 19:07, Chris Angelico wrote: > Topic branch: rosuav/sockopt > > Per Lance's suggestion, I've made a generic setsockopt() function. It > works only with integers, so it's not suitable for SO_LINGER, which > therefore should stay the way it is (linger() takes a magic parameter > of -1), but it works for any of the simple boolean options. > > As to shortcut functions, though, there are a few ways they can be done. > > 1) set_keepalive() always exists, even if SO_KEEPALIVE isn't > available. If you call it when there's no SO_KEEPALIVE, it sets errno > and returns failure. > 2) set_nodelay() exists only if TCP_NODELAY is available. > 3) setsockopt() itself is useless without the constants, and > Stdio.TCP_NODELAY will exist only if TCP_NODELAY is available. > > So in a Pike script, using setsockopt() requires either has_index() > run-time checks or #if compile-time checks for the options you want; > set_keepalive's model works easily if you know that the Pike version > you're targeting supports it; and set_nodelay's model lets you treat > older Pikes and systems without that feature the same way. > > I'd rather make it as easy as possible on the Pike code. Which way > makes more sense? > > ChrisA >