Clean up socket code.
Fix error message.