fix !O_NONBLOCK where ~O_NONBLOCK was meant

Using ! on a non-zero value will always return 0.

Also remove some duplicate and superfluous code in other places.
Merge pull request #2583 from laanwj/2013_04_netbase_bitfield

netbase: fix !O_NONBLOCK where ~O_NONBLOCK was meant