tcp: Check the return value from getsockopt