0

In the sockaddr_in struct, each member features a "sin" prefix. What do these prefixes represent?

enter image description here

Izzo
  • 4,461
  • 13
  • 45
  • 82
  • 1
    Probably **s**ockaddr_**in** – 001 Dec 29 '21 at 14:45
  • @JohnnyMopp I was curious if that was the case. It just seems unnecessary though and I don't see this naming technique used in many other structs. – Izzo Dec 29 '21 at 14:52
  • The struct is used as an input initializer when binding a socket.... For example:`address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons( PORT ); if (bind(server_fd, (struct sockaddr *)&address, sizeof(address))<0)` – ryyker Dec 29 '21 at 14:58
  • 2
    @Izzo Back in olden times, before Intellisense, people use Hungarian notation and other systems to give hints about the code in the names. So if you saw `s.sin_family`, you wouldn't need to lookup what `s` is - you'd see it was a `sockaddr_in`. – 001 Dec 29 '21 at 15:08
  • @JohnnyMopp that's very interesting and makes sense. – Izzo Dec 29 '21 at 19:46
  • @JohnnyMopp if you submit this response as an answer, I'll accept it. – Izzo Jan 02 '22 at 23:57

1 Answers1

0

https://stackoverflow.com/a/54715651/5451030

Take a look at that answer, it seems to be a shorten version of sockaddr_in

Alik.Koldobsky
  • 334
  • 1
  • 10