tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: struct sockaddr_storage issues



    Date:        Fri, 23 Dec 2022 13:10:51 -0500 (EST)
    From:        Mouse <mouse%Rodents-Montreal.ORG@localhost>
    Message-ID:  <202212231810.NAA25178%Stone.Rodents-Montreal.ORG@localhost>

  | I do not really understand why the socket calls (bind, accept, etc)
  | were designed to take length values when the sockaddrs themselves
  | contain lengths (Linux does not explain; I'm talking about the
  | pre-Linux days here, when UCB first created sockets).  Perhaps the
  | *_len fields postdate the API design or something?

They do, the length was added later.

In the original it was simply assumed that the AF told you what the
address looked like (exactly) and hence the size of an appropriate
sockaddr.   That turned out not to be true (for AF_LOCAL obviously,
that didn't exist initially) but also for some other protocols, that
are no longer really relevant to anything anyone cares about, but for
a short while were seen, in some quarters, as if they might be important.

In any case, having the length as a separate arg avoids the need to
fetch some of the sockaddr arg, just enough to get the length, and
then fetch the rest of it.

kre



Home | Main Index | Thread Index | Old Index