Hello, On Sun, Feb 13, 2011 at 12:42 AM, Ken Raeburn <raeb...@raeburn.org> wrote: > What platforms have sin_len in the generic sockaddr structure? The one I've > always seen is sa_len, and that's consistent with sa_family in terms of field > name prefixes. > > sockaddr -> sa_ > sockaddr_in -> sin_ > sockaddr_in6 -> sin6_ > sockaddr_storage -> ss_ > > I suspect you'd do fine if you ditched the test for sockaddr.sin_len and > tested either sockaddr_in.sin_len or sockaddr.sa_len. (And I'd expect an OS > to be consistent as to whether the _len field exists for each of the various > socket address structures.)
OS X, which I use, has a somewhat weird field-naming situation. The generic sockaddr structure has sa_len, but sockaddr_in has a sin_len field. The code I was fixing is creating a sockaddr_in, so in order to use the sa_len field I would have had to cast a sockaddr_in to a sockaddr, and it just seemed cleaner to use the sin_len field. It's no big deal either way, though - this would affect probably 10 or fewer lines of code no matter what. Noah