fix !O_NONBLOCK where ~O_NONBLOCK was meant
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.

MidasPaymentLTD/midascoin,MidasPaymentLTD/midascoin,MidasPaymentLTD/midascoin,MidasPaymentLTD/midascoin,MidasPaymentLTD/midascoin