sockaddr, sockaddr_storage, socklen_t
socket address
- Provided by: manpages-dev (Version: 6.19-3)
- Source: manpages
- Report a bug
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;
See sockaddr_in(3type) and sockaddr_in6(3type).
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)