[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
posix: Add server example for IPv6, because it was not obvious to me
From: |
Arne Babenhauserheide |
Subject: |
posix: Add server example for IPv6, because it was not obvious to me |
Date: |
Sat, 10 Nov 2018 01:51:10 +0100 |
User-agent: |
mu4e 1.0; emacs 25.3.1 |
From 0ce11db4c224a99ef70835ee63792321eac038d6 Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide <address@hidden>
Date: Sat, 10 Nov 2018 01:44:47 +0100
Subject: [PATCH] posix: Add server example for IPv6, because it was not
obvious to me
---
doc/ref/posix.texi | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 5cb68a292..674598d90 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -3504,6 +3504,29 @@ client.
(close client))))
@end example
address@hidden socket server example ipv6
+The following example uses an IPv6 socket listening on all addresses
address@hidden
+(let ((s (socket PF_INET6 SOCK_STREAM 0)))
+ (setsockopt s SOL_SOCKET SO_REUSEADDR 1)
+ (bind s AF_INET6 (inet-pton AF_INET6 "::") 2904)
+ (listen s 5)
+
+ (simple-format #t "Listening for clients in pid: ~S" (getpid))
+ (newline)
+
+ (while #t
+ (let* ((client-connection (accept s))
+ (client-details (cdr client-connection))
+ (client (car client-connection)))
+ (simple-format #t "Got new client connection: ~S"
+ client-details)
+ (newline)
+ ;; @r{Send back the greeting to the client port}
+ (display "Hello client\r\n" client)
+ (close client))))
address@hidden example
+
@node System Identification
@subsection System Identification
--
2.19.1
From 0ce11db4c224a99ef70835ee63792321eac038d6 Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide <address@hidden>
Date: Sat, 10 Nov 2018 01:44:47 +0100
Subject: [PATCH] posix: Add server example for IPv6, because it was not
obvious to me
---
doc/ref/posix.texi | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index 5cb68a292..674598d90 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -3504,6 +3504,29 @@ client.
(close client))))
@end example
address@hidden socket server example ipv6
+The following example uses an IPv6 socket listening on all addresses
address@hidden
+(let ((s (socket PF_INET6 SOCK_STREAM 0)))
+ (setsockopt s SOL_SOCKET SO_REUSEADDR 1)
+ (bind s AF_INET6 (inet-pton AF_INET6 "::") 2904)
+ (listen s 5)
+
+ (simple-format #t "Listening for clients in pid: ~S" (getpid))
+ (newline)
+
+ (while #t
+ (let* ((client-connection (accept s))
+ (client-details (cdr client-connection))
+ (client (car client-connection)))
+ (simple-format #t "Got new client connection: ~S"
+ client-details)
+ (newline)
+ ;; @r{Send back the greeting to the client port}
+ (display "Hello client\r\n" client)
+ (close client))))
address@hidden example
+
@node System Identification
@subsection System Identification
--
2.19.1
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- posix: Add server example for IPv6, because it was not obvious to me,
Arne Babenhauserheide <=