socket: capture errno after system calls.