Error with socketpair and getsockname

Marco Righele marco at righele.it
Wed Aug 5 09:39:03 PDT 2015


Il 2015-08-05 14:01 Romick ha scritto:
> On Wed, Aug 05, 2015 at 01:17:16PM +0200, Marco Righele wrote:
>> 
>>        len = sizeof(sa);
>>        if (getsockname(fds[0], &sa, &len)) {
>>            printf("getsockname error\n");
>>            return 1;
>>        }
>>        assert( type == SOCK_STREAM );
>>        assert( sa.sa_family == AF_UNIX );
>>    }
>> 
>> Instead of AF_UNIX the call to getsockname returns AF_UNSET.
>> Am I missing something ?
>> 
> 
> check len before use any of sa's fields.

You're right. In fact I should have checked getsockname(2) man page 
beforehand...


BUGS
      Names bound to sockets in the UNIX domain are inaccessible; 
getsockname
      returns a zero length name.


Thanks,
Marco




More information about the Users mailing list