Issue #22: should check the return code for getsockname and getpeername