unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: "Dr. Arne Babenhauserheide" <arne_bab@web.de>, guile-devel@gnu.org
Subject: Re: (web server) serving on both ipv6 and ipv4?
Date: Wed, 19 Jan 2022 09:51:07 +0100	[thread overview]
Message-ID: <3bbd5a2c267f9e58657b0087e26c92ed36d1b81b.camel@telenet.be> (raw)
In-Reply-To: <87k0ewi0w2.fsf@web.de>

[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]

Dr. Arne Babenhauserheide schreef op wo 19-01-2022 om 08:57 [+0100]:
> Hi,
> 
> 
> with both fibers server and (web server) there is a split between IPv4
> and IPv6:
> 
> 
> IPv4:
> 
>     (fibers:run-server handler-with-path #:family AF_INET #:port port #:addr INADDR_ANY)
> 
>     (run-server handler-with-path 'http `(#:host "localhost" #:family ,AF_INET #:addr ,INADDR_ANY #:port ,port))
> 
> 
> IPv6:
> 
>     (define s
>         (let ((s (socket AF_INET6 SOCK_STREAM 0)))
>             (setsockopt s SOL_SOCKET SO_REUSEADDR 1)
>             (bind s AF_INET6 (inet-pton AF_INET6 ip) port)
>             s))
>     (fibers:run-server handler-with-path #:family AF_INET6 #:port port #:addr (inet-pton AF_INET6 ip) #:socket s)
> 
>     (define s
>         (let ((s (socket AF_INET6 SOCK_STREAM 0)))
>             (setsockopt s SOL_SOCKET SO_REUSEADDR 1)
>             (bind s AF_INET6 (inet-pton AF_INET6 ip) port)
>             s))
>     (run-server handler-with-path 'http `(#:family ,AF_INET6 #:addr (inet-pton AF_INET6 ip) #:port ,port #:socket ,s))
> 
> 
> Is there a way to bind to both IPv6 and IPv4, so my server will react to
> requests regardless of whether a client reaches my computer over IPv4 or
> IPv6?

Maybe the IPV6_V6ONLY (see the ipv6(7) man page) is relevant here.
Alternatively, you could run two servers in parallel: one bound to an
IPv4 address and another bound to an IPv6 address.

Unfortunately, the fibers HTTP server calls 'run-fibers' (even if
there's already some scheduler), so each server will be run in its own
fresh scheduler, this might cause problems..

There's some code in 'cuirass' and 'gnunet-scheme' (see
<https://git.gnunet.org/gnunet-scheme.git/tree/web/server/fiberized.scm>)
that doesn't spawn its own scheduler.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

  reply	other threads:[~2022-01-19  8:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-19  7:57 (web server) serving on both ipv6 and ipv4? Dr. Arne Babenhauserheide
2022-01-19  8:51 ` Maxime Devos [this message]
2022-01-19 18:27   ` Greg Troxel
2022-01-20  7:24     ` Dr. Arne Babenhauserheide
2022-01-20 13:38       ` Greg Troxel
2022-01-19 13:07 ` Chris Vine
2022-01-19 13:44   ` Chris Vine
2022-01-19 13:53     ` Chris Vine
2022-01-19 21:12     ` Chris Vine
2022-01-19 21:42       ` Dr. Arne Babenhauserheide

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3bbd5a2c267f9e58657b0087e26c92ed36d1b81b.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=arne_bab@web.de \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).