+(defun make-host-ent (h)
+ (if (sb-grovel::foreign-nullp h) (name-service-error "gethostbyname"))
+ (let* ((length (sockint::hostent-length h))
+ (aliases (loop for i = 0 then (1+ i)
+ for al = (sb-alien:deref (sockint::hostent-aliases h) i)
+ while al
+ collect al))
+ (addresses
+ (loop for i = 0 then (1+ i)
+ for ad = (sb-alien:deref (sockint::hostent-addresses h) i)
+ until (sb-alien:null-alien ad)
+ collect (ecase (sockint::hostent-type h)
+ (#.sockint::af-inet
+ (assert (= length 4))
+ (let ((addr (make-array 4 :element-type '(unsigned-byte 8))))
+ (loop for i from 0 below length
+ do (setf (elt addr i) (sb-alien:deref ad i)))
+ addr))
+ (#.sockint::af-local
+ (sb-alien:cast ad sb-alien:c-string))))))
+ (make-instance 'host-ent
+ :name (sockint::hostent-name h)
+ :type (sockint::hostent-type h)
+ :aliases aliases
+ :addresses addresses)))
+