Check the return value from setsockopt and log errors

Fixes coverty 700269