fixing socket name
willem
itsme at xs4all.nl
Mon Mar 29 21:59:25 CEST 2010
On 2010-03-29 16:39:31, willem wrote:
> On 2010-03-29 12:52:11, Holger Freyther wrote:
>
>> On Monday 29 March 2010 12:39:48 willem wrote:
>>
>>
>>> the /tmp/osmoncon* sockets created by osmocon are created one character
>>> too short.
>>>
>>>
>> Can you explain?
>>
>>
> the sockaddr struct for named sockets is defined like this ( on my mac )
>
>
> struct sockaddr_un {
> unsigned char sun_len; /* sockaddr len including null */
> sa_family_t sun_family; /* [XSI] AF_UNIX */
> char sun_path[104]; /* [XSI] path name (gag) */
> };
>
> the sun_len value is ignored.
> but the total length of the struct passed to bind / connect
> should include it.
>
> without this fix, the second time i run './osmocon' it will complain:
> Failed to bind the unix domain socket
> since it tried to unlink the correct name, but called bind with a one
> char too short name.
>
now checked cygwin headers. there the sun_len member is missing.
the more portable way would be to use SUN_LEN(&local)
i also noticed that the cygwin version of 'bind' apparently ignores the
socklen_t parameter.
and internally uses strlen to find the length.
on freebsd and osx you should use the SUN_LEN macro to pass the correct
length of
the sockaddr_un struct.
willem
More information about the baseband-devel
mailing list