summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormatthieu <matthieu@openbsd.org>2004-12-31 18:31:15 +0000
committermatthieu <matthieu@openbsd.org>2004-12-31 18:31:15 +0000
commit9f44c7233490ca161f923e3872ea958db7145a8b (patch)
tree18cf74c3fbcdb5daf366a23be48092e5fc5dc5ef /lib
parentkludge around this build problem for now. (diff)
downloadwireguard-openbsd-9f44c7233490ca161f923e3872ea958db7145a8b.tar.xz
wireguard-openbsd-9f44c7233490ca161f923e3872ea958db7145a8b.zip
Document existence of struct sockaddr_storage and add an example.
hints by miod@ and jmc@, ok deraadt@
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/sys/accept.224
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2
index 7135aaf4747..1d3cb61d120 100644
--- a/lib/libc/sys/accept.2
+++ b/lib/libc/sys/accept.2
@@ -1,4 +1,4 @@
-.\" $OpenBSD: accept.2,v 1.15 2003/06/02 20:18:38 millert Exp $
+.\" $OpenBSD: accept.2,v 1.16 2004/12/31 18:31:15 matthieu Exp $
.\" $NetBSD: accept.2,v 1.7 1996/01/31 20:14:42 mycroft Exp $
.\"
.\" Copyright (c) 1983, 1990, 1991, 1993
@@ -77,6 +77,12 @@ The exact format of the
.Fa addr
parameter is determined by the domain in which the communication
is occurring.
+The structure
+.Li sockaddr_storage
+exists for greater portability.
+It is large enough to hold any of the types that may be returned in the
+.Fa addr
+parameter.
The
.Fa addrlen
is a value-result parameter; it should initially contain the
@@ -124,6 +130,22 @@ call providing only the control information, or by calling
The call returns \-1 on error.
If it succeeds, it returns a non-negative integer that is a descriptor
for the accepted socket.
+.Sh EXAMPLES
+The following code uses struct
+.Li sockaddr_storage
+to allocate enough space for the returned address:
+.Bd -literal -offset indent
+#include <sys/types.h>
+#include <sys/socket.h>
+
+struct sockaddr_storage addr;
+socklen_t len = sizeof(addr);
+int retcode;
+
+retcode = accept(s, (struct sockaddr *)&addr, &len)
+if ( etcode < 0)
+ errx(1, "accept");
+.Ed
.Sh ERRORS
The
.Fn accept