Prevent EINVAL in setsockopt

Several values are required to be ints rather than longs
but are not included in the if statement.
Merge pull request #199 from jleahy/master

Broken setsockopts