From 9d3ddd79b9aa53d4aca8a08cc9f45a6f06fd0e36 Mon Sep 17 00:00:00 2001 From: vibr Date: Thu, 14 Apr 2005 14:06:00 +0000 Subject: [PATCH] *delete GET-SOCKET-HOSTNAME-AND-PORTNUMBER (was buggy anyway) *rewrite GET-SOCKET-HOST-STRING --- scheme/lib/sunet-utilities.scm | 21 ++++++--------------- scheme/packages.scm | 3 +-- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/scheme/lib/sunet-utilities.scm b/scheme/lib/sunet-utilities.scm index 81a9660..4eb882b 100644 --- a/scheme/lib/sunet-utilities.scm +++ b/scheme/lib/sunet-utilities.scm @@ -5,23 +5,14 @@ ;;; For copyright information, see the file COPYING which comes with ;;; the distribution. -;;; interpolate hostname/IP address and portnumber from our request's net connection. -;;; return host as string and portnumber as integer. -(define (get-socket-hostname-and-portnumber req) - (let ((addr (socket-local-address (request-socket req)))) - (with-fatal-error-handler - (lambda (c more) - (call-with-values (lambda ()(socket-address->internet-address addr)) - (lambda (ipaddr portnum) (values (format-internet-host-address ipaddr) portnum)))) - (values (host-info:name (host-info addr)) (service-info:port (service-info addr)))))) - ;; interpolate host info from our request's net connection. -;; return string "foo.bar.org:7777" or "134.2.12.72:7777" +;; return string. Example: "134.2.12.72:7777" (define (get-socket-host-string req) - (call-with-values - (lambda () (get-socket-hostname-and-portnumber req)) - (lambda (host portnum) (string-append host ":" (number->string portnum))))) - + (let ((addr (socket-local-address (request-socket req)))) + (call-with-values + (lambda ()(socket-address->internet-address addr)) + (lambda (ipaddr portnum) + (string-append (format-internet-host-address ipaddr) ":" (number->string portnum)))))) ;;; interpolate hostname or IP address from socket local address. return a string (define (host-name-or-ip addr) diff --git a/scheme/packages.scm b/scheme/packages.scm index 32490d9..3d53e80 100644 --- a/scheme/packages.scm +++ b/scheme/packages.scm @@ -238,8 +238,7 @@ format-port)) (define-interface sunet-utilities-interface - (export get-socket-hostname-and-portnumber - get-socket-host-string + (export get-socket-host-string host-name-or-ip on-interrupt socket-address->string