6

I am new to UNIX socket programming and I am wondering what is "sin" in sin_addr, sin_family etc, short for? And what does "in" mean or is short for in struct socketaddr_in?

Thank you!

OEurix
  • 393
  • 4
  • 19

1 Answers1

7

I think it is shorthand for the name of the struct (sockaddr_in) that the member-variables are a part of.

Similarly, the variables inside sockaddr_in6 all start with the prefix sin6_, and the variables inside sockaddr start with the prefix sa_, and so on.

in is presumably shorthand for "internet".

Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
  • 3
    This convention generally holds up for other `sockaddr` types as well, like `sun_` for `sockaddr_un` members, `sll_` for `sockaddr_ll` members, `ss_` for `sockaddr_storage` members, etc (it is not used in Microsoft's `SOCKADDR_BTH`, though). – Remy Lebeau Feb 15 '19 at 21:14