Optimize sb-bsd-sockets a bit.

Add declarations and rearrange some code to reduce consing.