|
NAME | LIBRARY | SYNOPSIS | DESCRIPTION | STANDARDS | HISTORY | NOTES | SEE ALSO | COLOPHON |
|
|
|
sockaddr(3type) sockaddr(3type)
sockaddr, sockaddr_storage, socklen_t - socket address
Standard C library (libc)
#include <sys/socket.h>
struct sockaddr {
sa_family_t sa_family; /* Address family */
char sa_data[]; /* Socket address */
};
struct sockaddr_storage {
sa_family_t ss_family; /* Address family */
};
typedef /* ... */ socklen_t;
typedef /* ... */ sa_family_t;
sockaddr
Describes a socket address.
sockaddr_storage
A structure at least as large as any other sockaddr_*
address structures. It's aligned so that a pointer to it
can be cast as a pointer to other sockaddr_* structures and
used to access its fields.
socklen_t
Describes the length of a socket address. This is an
integer type of at least 32 bits.
sa_family_t
Describes a socket's protocol family. This is an unsigned
integer type.
Internet domain sockets
See sockaddr_in(3type) and sockaddr_in6(3type).
UNIX domain sockets
See sockaddr_un(3type).
POSIX.1-2024.
POSIX.1-2001.
socklen_t was invented by POSIX. See also accept(2).
These structures were invented before modern ISO C strict-aliasing
rules. If aliasing rules are applied strictly, these structures
would be extremely difficult to use without invoking undefined
behavior. POSIX.1-2024 fixed this by requiring that
implementations make sure that these structures can be safely used
as they were designed.
socklen_t is also defined in <netdb.h>.
sa_family_t is also defined in <netinet/in.h> and <sys/un.h>.
accept(2), bind(2), connect(2), getpeername(2), getsockname(2),
getsockopt(2), sendto(2), setsockopt(2), socket(2), socketpair(2),
getaddrinfo(3), gethostbyaddr(3), getnameinfo(3), htonl(3),
ipv6(7), socket(7)
This page is part of the man-pages (Linux kernel and C library
user-space interface documentation) project. Information about
the project can be found at
⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report
for this manual page, see
⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
This page was obtained from the tarball man-pages-6.18.tar.gz
fetched from
⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
2026-05-24. If you discover any rendering problems in this HTML
version of the page, or you believe there is a better or more up-
to-date source for the page, or you have corrections or
improvements to the information in this COLOPHON (which is not
part of the original manual page), send a mail to
man-pages@man7.org
Linux man-pages 6.18 2026-02-08 sockaddr(3type)
Pages that refer to this page: sockaddr_in(3type), sockaddr_in6(3type), ip(7)