sockaddr_storage
Hal Murray
hmurray at megapathdsl.net
Mon Jan 23 04:10:36 UTC 2017
> First, to eliminate a union from our source code. Second, to move from a
> private type to a POSIX-standardized one that is likely to have a binding in
> any language we move to.
Just because it's POSIX doesn't mean it's any good. Unless there is stylized
code for using sockaddr_storage, I would try hard to avoid it. There is
nothing in there to help the type checker.
If the only problem with space is in the mrulist, we can fix that easily.
All the MRU list needs is a flag to specify if the IP address is 4 or 6, the
address, and the port number. There is extra cruft in the sockaddr_in6 so it
wouldn't cost any space to use a non-union there. We could save the space of
the IPv4 address with a bit of kludgery.
esr at thyrsus.com said:
>> unions are a reasonably clean way of handling things like
>> network packets. How does Go do that?
> With an opaque object structure. I don't know if the packet storage is
Barf. The example URL you provided looked horrible to me.
I forget what they called it, but Mesa had a sane way of handling things like
network packets. The basic idea is that there was a way to select which
branch of the union you wanted to use, and you told the compiler about it.
Then you could do a select and each branch of the select could only access
the appropriate fields.
--
These are my opinions. I hate spam.
More information about the devel
mailing list