The third argument of bind()

       int bind(int socket, const struct sockaddr *address,
              socklen_t address_len);

Man page says it specifies the length of the sockaddr structure pointed to by the address argument.

But why bind() can't figure out the length itself, since the first member (eg:AF_INET or AF_INET6...) of sockaddr structure implies the actual structure which contains it. So I think bind() can figure out the length of the sockaddr structure by inspecting address->sa_family.

You may say that, these strctures are diffrent in different OS. But the implemnetation of bind() can also be designed for diffrent OS. The length of these structures are constant in the same OS.

Who can explain it?

Thx!!!

Remember how many different protocols go through these same socket calls. These structures are all the same size, but there may be other protocols where they're not.

I'm sure you know the actual spelling.

Do you mean there may be a protocal using two diffrent structures? Could you show an example?

Yes, but I don't think thx express less appreciation than thanks. I'm not a native speaker, but I see thx is used any where.

I don't know of one myself, but it allows them, that's the point. These are supposed to be universal socket calls, not just tcp ones.

Considering not using netspeak is part of the rules you agreed to when you signed up, but you went ahead and used netspeak anyway, I think it does.

It is popular on telephones, where typing is difficult.

Thank you for your reply. I am sorry to break the rule, and will read them narrowly again.