This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Talking to a WWW-server


Mikael Djurfeldt <mdj@nada.kth.se> writes:

> Hmm...
> 
> 0* [www:get "http://www.nada.kth.se/~mdj"]
> 1  (let ((url #)) (case (url:scheme url) (# #) ...))
>    ...
> 2  (let ((msg #)) (http:message-body msg))
> 3* [http:get "www.nada.kth.se" #f ...]
> 4  (let ((p #) (path #)) (http:request p (string-append "GET " path ...) ...))
> 5* [http:connect "www.nada.kth.se" 80]
> 6  (let* ((port #) (tcp #) (addr #) ...) (connect sock AF_INET ...) ...)
> 7* [car ...
> 8*  [vector-ref ...
> 9*   [gethost "www.nada.kth.se"]
> 
> But
> 
> (gethost "www.nada.kth.se")
> --> #("web.nada.kth.se" ("www.nada.kth.se") 2 4 (2196627010))
> 
> ???

I'm afraid I haven't yet learnt most of UNIX system calls.

I looked at the man page for gethostbyname, saw something about static
storage and guessed that the patch below would fix the problem.

It does.

Why?

Is it the correct fix?

/mdj

*** http.scm~	Mon Jun 23 19:20:24 1997
--- http.scm	Mon Oct 20 21:10:41 1997
***************
*** 113,119 ****
  (define-public (http:connect host . args)
    (let* ((port (if (null? args) 80 (car args)))
  	 (tcp (vector-ref (getproto "tcp") 2))
! 	 (addr (car (vector-ref (gethost host) 4)))
  	 (sock (socket AF_INET SOCK_STREAM tcp)))
      (connect sock AF_INET addr port)
      sock))
--- 113,119 ----
  (define-public (http:connect host . args)
    (let* ((port (if (null? args) 80 (car args)))
  	 (tcp (vector-ref (getproto "tcp") 2))
! 	 (addr (car (vector-ref (begin (sethostent) (gethost host)) 4)))
  	 (sock (socket AF_INET SOCK_STREAM tcp)))
      (connect sock AF_INET addr port)
      sock))