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] |
Hi there.
Just a note, the connect, listen and bind subr's from socket.c are very
unschemisch in that they don't return anything.
You have to say
guile> (define sock (socket AF_INET SOCK_STREAM 0))
guile> (connect sock AF_INET
(car (array-ref (gethostbyname "server") 4))
port)
instead of just
guile (define sock (connect (socket AF_INET SOCK_STREAM 0) AF_INET
(car (array-ref (gethostbyname "server") 4))
port))
Which would be much more elegant, IMHO.
The following patch fixes this "bug" in connect, listen and bind.
diff -urN guile-core/libguile/socket.c guile-core-new/libguile/socket.c
--- guile-core/libguile/socket.c Mon Oct 19 23:36:26 1998
+++ guile-core-new/libguile/socket.c Mon Nov 30 08:12:53 1998
@@ -395,7 +395,7 @@
scm_syserror (s_connect);
scm_must_free ((char *) soka);
SCM_ALLOW_INTS;
- return SCM_UNSPECIFIED;
+ return sock;
}
SCM_PROC (s_bind, "bind", 3, 0, 1, scm_bind);
@@ -421,7 +421,7 @@
if (rv == -1)
scm_syserror (s_bind);
scm_must_free ((char *) soka);
- return SCM_UNSPECIFIED;
+ return sock;
}
SCM_PROC (s_listen, "listen", 2, 0, 0, scm_listen);
@@ -438,7 +438,7 @@
fd = fileno ((FILE *)SCM_STREAM (sock));
if (listen (fd, SCM_INUM (backlog)) == -1)
scm_syserror (s_listen);
- return SCM_UNSPECIFIED;
+ return sock;
}
/* Put the components of a sockaddr into a new SCM vector. */
Hack on,
-forcer
--
((email . "forcer@mindless.com") (www . "http://webserver.de/forcer/")
(irc . "forcer@#StarWars (IRCnet)") (pgp . "key available on my website"))