unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Allow specifying the socket style for open-socket-for-uri.
@ 2023-07-20 14:08 Christopher Baines
  2023-07-24 20:55 ` Maxime Devos
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Baines @ 2023-07-20 14:08 UTC (permalink / raw)
  To: guile-devel

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.

* 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."
   (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))
-- 
2.41.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-24 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).