This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: What type are internet addresses?
- To: guile at sourceware dot cygnus dot com
- Subject: Re: What type are internet addresses?
- From: "C. Ray C." <crayc at 206 dot 31 dot 63 dot 15>
- Date: Fri, 11 Feb 2000 02:02:20 -0600
- References: <38A3A783.A4CF4249@physics.uq.edu.au>
On Fri, Feb 11, 2000 at 04:09:07PM +1000, Rodney Polkinghorne wrote:
> Why doesn't the following work, and how does one construct an internet
> address for guile's connect function? What goes into the third
> argument?
connect <socket> <family> <address> <port>
> A pointer to the documentation for guile's socket functions would be
> appreciated. If there isn't any, I'd be happy to write some once I find
> out how they work myself.
The documentation is in the guile-doc package (in the ref directory),
which is in CVS. You can also get a snapshot from
ftp://ftp.red-bean.com/pub/guile/snapshots/guile-doc-snap.tar.gz.
Just ranting here, but it's almost impossible to do anything with Guile
unless you have guile-doc. It's made even worse by the fact that
the GNU web page claims the snapshot doesn't even exist! Even in it's
incomplete state I think it should go into the main Guile package.
> guile> (version)
> "1.3"
> guile> (define s (socket AF_INET SOCK_STREAM 0))
> guile> (define a (gethostbyname "127.0.0.1"))
> guile> a
> #("127.0.0.1" () 2 4 (2130706433))
> guile> (define addr (car (vector-ref a 4)))
> guile> (connect s addr 0)
> ERROR: In procedure gsubr-apply in expression (connect s addr ...):
> ERROR: Wrong type argument in position 2: 2130706433
> ABORT: (wrong-type-arg)
I would rewrite it thus:
(define s (socket AF_INET SOCK_STREAM 0))
(define a (car (hostent:addr-list (gethostbyname "127.0.0.1"))))
(connect s AF_INET a 0)
After running that you should get an error saying "Connection refused",
unless you happen to something waiting for connections on port 0.