diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:40:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:40:15 +0000 |
commit | 399644e47874bff147afb19c89228901ac39340e (patch) | |
tree | 1c4c0b733f4c16b5783b41bebb19194a9ef62ad1 /man3type/sockaddr.3type | |
parent | Initial commit. (diff) | |
download | manpages-399644e47874bff147afb19c89228901ac39340e.tar.xz manpages-399644e47874bff147afb19c89228901ac39340e.zip |
Adding upstream version 6.05.01.upstream/6.05.01
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'man3type/sockaddr.3type')
-rw-r--r-- | man3type/sockaddr.3type | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/man3type/sockaddr.3type b/man3type/sockaddr.3type new file mode 100644 index 0000000..dacc9ad --- /dev/null +++ b/man3type/sockaddr.3type @@ -0,0 +1,154 @@ +.\" Copyright (c) 2020-2022 by Alejandro Colomar <alx@kernel.org> +.\" and Copyright (c) 2020 by Michael Kerrisk <mtk.manpages@gmail.com> +.\" +.\" SPDX-License-Identifier: Linux-man-pages-copyleft +.\" +.\" +.TH sockaddr 3type 2023-04-22 "Linux man-pages 6.05.01" +.SH NAME +sockaddr, sockaddr_storage, sockaddr_in, sockaddr_in6, sockaddr_un, socklen_t, +in_addr, in6_addr, in_addr_t, in_port_t, +\- socket address +.SH LIBRARY +Standard C library +.RI ( libc ) +.SH SYNOPSIS +.EX +.B #include <sys/socket.h> +.PP +.B struct sockaddr { +.BR " sa_family_t sa_family;" " /* Address family */" +.BR " char sa_data[];" " /* Socket address */" +.B }; +.PP +.B struct sockaddr_storage { +.BR " sa_family_t ss_family;" " /* Address family */" +.B }; +.PP +.BR typedef " /* ... */ " socklen_t; +.BR typedef " /* ... */ " sa_family_t; +.PP +.EE +.SS Internet domain sockets +.EX +.B #include <netinet/in.h> +.PP +.B struct sockaddr_in { +.BR " sa_family_t sin_family;" " /* " AF_INET " */" +.BR " in_port_t sin_port;" " /* Port number */" +.BR " struct in_addr sin_addr;" " /* IPv4 address */" +.B }; +.PP +.B struct sockaddr_in6 { +.BR " sa_family_t sin6_family;" " /* " AF_INET6 " */" +.BR " in_port_t sin6_port;" " /* Port number */" +.BR " uint32_t sin6_flowinfo;" " /* IPv6 flow info */" +.BR " struct in6_addr sin6_addr;" " /* IPv6 address */" +.BR " uint32_t sin6_scope_id;" " /* Set of interfaces for a scope */" +.B }; +.PP +.B struct in_addr { +.B " in_addr_t s_addr;" +.B }; +.PP +.B struct in6_addr { +.B " uint8_t s6_addr[16];" +.B }; +.PP +.B typedef uint32_t in_addr_t; +.B typedef uint16_t in_port_t; +.EE +.SS UNIX domain sockets +.EX +.B #include <sys/un.h> +.PP +.B struct sockaddr_un { +.BR " sa_family_t sun_family;" " /* Address family */" +.BR " char sun_path[];" " /* Socket pathname */" +.B }; +.EE +.SH DESCRIPTION +.TP +.I sockaddr +Describes a socket address. +.TP +.I sockaddr_storage +A structure at least as large as any other +.IR sockaddr_ * +address structures. +It's aligned so that a pointer to it can be cast +as a pointer to other +.IR sockaddr_ * +structures and used to access its fields. +.TP +.I socklen_t +Describes the length of a socket address. +This is an integer type of at least 32 bits. +.TP +.I sa_family_t +Describes a socket's protocol family. +This is an unsigned integer type. +.SS Internet domain sockets +.TP +.I sockaddr_in +Describes an IPv4 Internet domain socket address. +The +.I sin_port +and +.I sin_addr +members are stored in network byte order. +.TP +.I sockaddr_in6 +Describes an IPv6 Internet domain socket address. +The +.I sin6_addr.s6_addr +array is used to contain a 128-bit IPv6 address, +stored in network byte order. +.SS UNIX domain sockets +.TP +.I sockaddr_un +Describes a UNIX domain socket address. +.SH STANDARDS +POSIX.1-2008. +.SH HISTORY +POSIX.1-2001. +.PP +.I socklen_t +was invented by POSIX. +See also +.BR accept (2). +.PP +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 Issue 8 will fix this by requiring that implementations +make sure that these structures +can be safely used as they were designed. +.SH NOTES +.I socklen_t +is also defined in +.IR <netdb.h> . +.PP +.I sa_family_t +is also defined in +.I <netinet/in.h> +and +.IR <sys/un.h> . +.SH SEE ALSO +.BR accept (2), +.BR bind (2), +.BR connect (2), +.BR getpeername (2), +.BR getsockname (2), +.BR getsockopt (2), +.BR sendto (2), +.BR setsockopt (2), +.BR socket (2), +.BR socketpair (2), +.BR getaddrinfo (3), +.BR gethostbyaddr (3), +.BR getnameinfo (3), +.BR htonl (3), +.BR ipv6 (7), +.BR socket (7) |