1.0.3.6: Make sb-bsd-sockets use getaddrinfo/getnameinfo where available
[sbcl.git] / contrib / sb-bsd-sockets / inet.lisp
index 4cc0684..e6265ed 100644 (file)
@@ -27,6 +27,13 @@ Examples:
        #'parse-integer
        (split dotted-quads nil '(#\.))))
 
+(define-condition unknown-protocol ()
+  ((name :initarg :name
+         :reader unknown-protocol-name))
+  (:report (lambda (c s)
+             (format s "Protocol not found: ~a" (prin1-to-string
+                                                 (unknown-protocol-name c))))))
+
 ;;; getprotobyname only works in the internet domain, which is why this
 ;;; is here
 (defun get-protocol-by-name (name)      ;exported
@@ -35,6 +42,8 @@ using getprotobyname(2) which typically looks in NIS or /etc/protocols"
   ;; for extra brownie points, could return canonical protocol name
   ;; and aliases as extra values
   (let ((ent (sockint::getprotobyname name)))
+    (if (sb-alien::null-alien ent)
+        (error 'unknown-protocol :name name))
     (sockint::protoent-proto ent)))
 
 ;;; our protocol provides make-sockaddr-for, size-of-sockaddr,