guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (web server) serving on both ipv6 and ipv4?


From: Maxime Devos
Subject: Re: (web server) serving on both ipv6 and ipv4?
Date: Wed, 19 Jan 2022 09:51:07 +0100
User-agent: Evolution 3.38.3-1

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: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]