In the sockaddr_in struct, each member features a "sin" prefix. What do these prefixes represent?
Asked
Active
Viewed 170 times
0
-
1Probably **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 Answers
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