[FFmpeg-devel] [PATCH/RFC] Prefer getaddrinfo over gethostbyname

Dave Yeo daveryeo
Tue Jan 12 20:17:51 CET 2010


On 01/12/10 09:21 am, Martin Storsj? wrote:
> On Tue, 12 Jan 2010, Ronald S. Bultje wrote:
>
>> So, I think the attached would be easier. RFC-2553 defines the storage
>> size to be 128, and although it may be more because of alignment, the
>> result of the attached version would always be>=128, as defined in
>> RFC-2553.
>
> I'm not sure this is guaranteed to work. As described in the same RFC,
> sockaddr may include a member "sa_len" before the sa_family member, so the
> location within sockaddr_storage would have to match that. And the size of
> sa_family isn't necessarily 16 bit. (The same RFC says that it is 16 bit
> "on most implementations", but if sa_len is present, it probably is 8 bit
> instead, but afaik, an implementation is free to layout it in any other
> way.)
>
> So I'm really at a loss for how to provide a reliable replacement for this
> struct including the correct fields.
>

FYI sa_len is implemented like this here (the TCPV40HDRS are 
depreciated) on OS/2

struct sockaddr {
#ifdef TCPV40HDRS
         u_short sa_family;              /* address family */
         char    sa_data[14];            /* up to 14 bytes of direct 
address */
#else
         u_char  sa_len;                 /* total length */
         u_char  sa_family;              /* address family */
         char    sa_data[14];            /* actually longer; address 
value */
#endif
};

Dave




More information about the ffmpeg-devel mailing list