-
November 10th, 2023, 07:27 AM
#1
structure sockaddr
What is reason to put data (ip, port) into structure of sockaddr to use connect primitive or bind ?
It could to be easier to pass as single parameters (ip or ports) instead to pass the structure ?
Why It's implemented in this way ?
-
November 11th, 2023, 01:06 AM
#2
Re: structure sockaddr
https://www.man7.org/linux/man-pages/man2/bind.2.html
There are many different kinds of sockets. sockaddr is just the base type (think C++ base class).
sockaddr_in https://www.man7.org/linux/man-pages/man7/ip.7.html
sockaddr_in6 https://www.man7.org/linux/man-pages/man7/ipv6.7.html
sockaddr_un https://www.man7.org/linux/man-pages/man7/unix.7.html
and so on.
So changing from ipv4 to ipv6 say just involves changing/initialising instances of sockaddr_in to be sockaddr_in6.
-
November 12th, 2023, 05:50 AM
#3
Re: structure sockaddr
 Originally Posted by salem_c
I'm referencing to this one sockaddr_in
Why it has been implemented a structure to contain af_family, port and ip address ?
-
November 12th, 2023, 07:09 AM
#4
Re: structure sockaddr
> Why it has been implemented a structure to contain af_family, port and ip address ?
Because those are things you need to know to create an IP socket.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|