From: Maxime Devos <maximedevos@telenet.be>
To: Christopher Baines <mail@cbaines.net>, guile-devel@gnu.org
Subject: Re: [PATCH] Allow specifying the socket style for open-socket-for-uri.
Date: Mon, 24 Jul 2023 22:55:38 +0200 [thread overview]
Message-ID: <2985a0d6-5f80-d226-1092-8419c08e6a46@telenet.be> (raw)
In-Reply-To: <20230720140838.24179-1-mail@cbaines.net>
[-- Attachment #1.1.1: Type: text/plain, Size: 2558 bytes --]
Op 20-07-2023 om 16:08 schreef Christopher Baines:
> Since this allows specifying additional behaviours for the socket
> through using SOCK_CLOEXEC and/or SOCK_NONBLOCK (when bitwise or'ed with
> SOCK_STREAM).
>
> Note that Guile/guile-gnutls currently doesn't support performing the
> TLS handshake on a non-blocking socket, so this currently won't work.
I would think that it currently works for _http_. (https is another
matter of course.)
> * module/web/client.scm (open-socket-for-uri): Allow specifying the
> socket style.
> ---
> module/web/client.scm | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/module/web/client.scm b/module/web/client.scm
> index 6c54c5021..a5405d17f 100644
> --- a/module/web/client.scm
> +++ b/module/web/client.scm
> @@ -317,9 +317,11 @@ host name without trailing dot."
> (read-response port))
>
> (define* (open-socket-for-uri uri-or-string
> - #:key (verify-certificate? #t))
> + #:key (verify-certificate? #t)
> + (socket-style SOCK_STREAM))
> "Return an open input/output port for a connection to URI-OR-STRING.
> -When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates."
> +When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates.
> +SOCKET-STYLE is passed as the second argument to the socket procedure."
I think it should mention that socket-style doesn't work yet for https.
> (define uri
> (ensure-uri-reference uri-or-string))
> (define https?
> @@ -346,7 +348,9 @@ When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates."
> (let* ((ai (car addresses))
> (s (with-fluids ((%default-port-encoding #f))
> ;; Restrict ourselves to TCP.
> - (socket (addrinfo:fam ai) SOCK_STREAM IPPROTO_IP))))
> + (socket (addrinfo:fam ai)
> + socket-style
> + IPPROTO_IP))))
> (catch 'system-error
> (lambda ()
> (connect s (addrinfo:addr ai))
I don't think that #:socket-style SOCK_SEQPACKET makes much sense, so I
would propose having a #:socket-flags argument instead. Also,
describing the new argument in terms of how it is used in the
implementation doesn't seem great to me -- I would instead propose doing
what the documentation 'accept' does with its 'flags' argument.
Best regards,
Maxime.
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
prev parent reply other threads:[~2023-07-24 20:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 14:08 [PATCH] Allow specifying the socket style for open-socket-for-uri Christopher Baines
2023-07-24 20:55 ` Maxime Devos [this message]
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=2985a0d6-5f80-d226-1092-8419c08e6a46@telenet.be \
--to=maximedevos@telenet.be \
--cc=guile-devel@gnu.org \
--cc=mail@cbaines.net \
/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).