Fix typo and purify logic in b_sock.c