Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When #+ipv6 also try to resolve an IPv4 address if the connection cannot be established with the IPv6 address. #75

Closed
informatimago opened this issue Jul 11, 2021 · 2 comments

Comments

@informatimago
Copy link

Related to #66

IMO, there's little reason to split the implementation in two for #-ipv6 and #+ipv6 (openmcl.lisp vs clozure.lisp).
In any case, when #+ipv6, if there is no server behind the IPv6 address, try the IPv4 address!
eg. in clozure.lisp (perhaps other places would apply too):

#+ipv6
(defun socket-connect (host port &key (protocol :stream) element-type
                                   timeout deadline nodelay
                                   local-host local-port)
  (when (eq nodelay :if-supported)
    (setf nodelay t))
  (with-mapped-conditions (nil host)
    (let (remote local mcl-sock)
      (loop
        :for address-family :in '(:internet6 :internet)
        :do (tagbody
               (setf remote  (when (and host port)
		                       (openmcl-socket:resolve-address :host (host-to-hostname host)
						                                       :port port
						                                       :socket-type protocol
                                                               :address-family address-family))
                     local   (when (and local-host local-port)
		                       (openmcl-socket:resolve-address :host (host-to-hostname local-host)
						                                       :port local-port
						                                       :socket-type protocol
                                                               :address-family address-family))
                     mcl-sock (handler-bind
                                  ((ccl:socket-creation-error
                                     (lambda (err)
                                       (if (eq address-family :internet6) ; the first try, let's ignore the error
                                           (go :continue))
                                       (signal err))))  
                                (apply #'openmcl-socket:make-socket
			                           `(:type ,protocol
			                                   ,@(when (or remote local)
				                                   `(:address-family ,(openmcl-socket:socket-address-family (or remote local))))
			                                   ,@(when remote
				                                   `(:remote-address ,remote))
			                                   ,@(when local
				                                   `(:local-address ,local))
			                                   :format ,(to-format element-type protocol)
			                                   :external-format ,ccl:*default-external-format*
			                                   :deadline ,deadline
			                                   :nodelay ,nodelay
			                                   :connect-timeout ,timeout
			                                   :input-timeout ,timeout))))
               (loop-finish)
             :continue))
      (ecase protocol
        (:stream
         (make-stream-socket :stream mcl-sock :socket mcl-sock))
        (:datagram
         (make-datagram-socket mcl-sock :connected-p (and remote t)))))))
@informatimago informatimago changed the title When #+ipv6 also try to resolve an IPv4 address if the connection cannot be established with the IPv6 adderss. When #+ipv6 also try to resolve an IPv4 address if the connection cannot be established with the IPv6 address. Oct 25, 2021
@binghe
Copy link
Member

binghe commented Mar 13, 2022

Hi,

I remember the #+ipv6 division in clozure.lisp was mainly to separate code for CCL 1.11 and all prior versions (<=1.10) which doesn't support IPv6 at all. CCL push :clozure and :ipv6 into *features* only since version 1.11, and usocket uses this observation and to select "modern" code for certain functions for CCL 1.11 afterwards. So this is basically a historical and compatibility reason.

Regards,

Chun

@binghe
Copy link
Member

binghe commented Mar 13, 2022

Consider this issue closed since there's no bug reported here. I think it's better to keep the current design to make sure usocket continues supporting all historical CCL / OpenMCL versions, e.g. very old versions for PPC Mac OS X.

@binghe binghe closed this as completed Mar 13, 2022
binghe added a commit that referenced this issue Jul 28, 2022
…on cannot be established with the IPv6 address. #75 (patch by Pascal J. Bourguignon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants