1sockaddr(3type)                                                sockaddr(3type)
2
3
4

NAME

6       sockaddr,  sockaddr_storage,  sockaddr_in,  sockaddr_in6,  sockaddr_un,
7       socklen_t, in_addr, in6_addr, in_addr_t, in_port_t, - socket address
8

LIBRARY

10       Standard C library (libc)
11

SYNOPSIS

13       #include <sys/socket.h>
14
15       struct sockaddr {
16           sa_family_t     sa_family;      /* Address family */
17           char            sa_data[];      /* Socket address */
18       };
19
20       struct sockaddr_storage {
21           sa_family_t     ss_family;      /* Address family */
22       };
23
24       typedef /* ... */ socklen_t;
25       typedef /* ... */ sa_family_t;
26
27   Internet domain sockets
28       #include <netinet/in.h>
29
30       struct sockaddr_in {
31           sa_family_t     sin_family;     /* AF_INET */
32           in_port_t       sin_port;       /* Port number */
33           struct in_addr  sin_addr;       /* IPv4 address */
34       };
35
36       struct sockaddr_in6 {
37           sa_family_t     sin6_family;    /* AF_INET6 */
38           in_port_t       sin6_port;      /* Port number */
39           uint32_t        sin6_flowinfo;  /* IPv6 flow info */
40           struct in6_addr sin6_addr;      /* IPv6 address */
41           uint32_t        sin6_scope_id;  /* Set of interfaces for a scope */
42       };
43
44       struct in_addr {
45           in_addr_t s_addr;
46       };
47
48       struct in6_addr {
49           uint8_t   s6_addr[16];
50       };
51
52       typedef uint32_t in_addr_t;
53       typedef uint16_t in_port_t;
54
55   UNIX domain sockets
56       #include <sys/un.h>
57
58       struct sockaddr_un {
59           sa_family_t     sun_family;     /* Address family */
60           char            sun_path[];     /* Socket pathname */
61       };
62

DESCRIPTION

64       sockaddr
65              Describes a socket address.
66
67       sockaddr_storage
68              A structure at least as large as any  other  sockaddr_*  address
69              structures.  It's aligned so that a pointer to it can be cast as
70              a pointer to other sockaddr_* structures and used to access  its
71              fields.
72
73       socklen_t
74              Describes  the  length  of a socket address.  This is an integer
75              type of at least 32 bits.
76
77       sa_family_t
78              Describes a socket's protocol family.  This is an unsigned inte‐
79              ger type.
80
81   Internet domain sockets
82       sockaddr_in
83              Describes  an IPv4 Internet domain socket address.  The sin_port
84              and sin_addr members are stored in network byte order.
85
86       sockaddr_in6
87              Describes  an  IPv6  Internet  domain   socket   address.    The
88              sin6_addr.s6_addr  array  is  used to contain a 128-bit IPv6 ad‐
89              dress, stored in network byte order.
90
91   UNIX domain sockets
92       sockaddr_un
93              Describes a UNIX domain socket address.
94

STANDARDS

96       POSIX.1-2008.
97

HISTORY

99       POSIX.1-2001.
100
101       socklen_t was invented by POSIX.  See also accept(2).
102

NOTES

104       socklen_t is also defined in <netdb.h>.
105
106       sa_family_t is also defined in <netinet/in.h> and <sys/un.h>.
107

SEE ALSO

109       accept(2), bind(2), connect(2),  getpeername(2),  getsockname(2),  get‐
110       sockopt(2),  sendto(2), setsockopt(2), socket(2), socketpair(2), getad‐
111       drinfo(3),   gethostbyaddr(3),   getnameinfo(3),   htonl(3),   ipv6(7),
112       socket(7)
113
114
115
116Linux man-pages 6.04              2023-04-03                   sockaddr(3type)
Impressum