This is the mail archive of the guile@sourceware.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: sockets are not really ports?


| I am working on a database system which will be accessed via web
| browsers, and I am using guile 1.3.4 to do it all.
| 
| While implementing the server side of HTTP, I have come across three
| annoying things:
| 	accept blocks all threads
| 	select won't take a socket port
| 	set-current-input-port won't take a socket port
| 
| The first two are easy enough to get around, I just wrote this:
| 
| (define (caccept s)
|     (let ((fd (list (port->fdes s))))
|         (if (null? (car (select fd '() '())))
|             (caccept s)
|             (accept s))))
| 
| The third problem basically means I have to store the port for the
| connection and keep specifying it to every output procedure. So I'm
| wondering, is there some reason for this? And if not, how can I fix it?

I can't reproduce the 2nd or 3rd problems, using the CVS version.  I
also can't remember any bug that would have caused them in 1.3.4.

E.g., 

(let ((s (socket AF_INET SOCK_STREAM 0)))
  (bind s AF_INET INADDR_LOOPBACK 14212)
  (listen s 1)
  (let ((t (car (accept s))))
    (set-current-output-port t)
    (set-current-input-port t)
    (set-current-error-port t)))

then "telnet localhost 14212".

works for me.  Can anyone supply further details of the problems?

Regarding the 1st problem, I don't think accept is the only procedure
that causes thread-blocking.  It would go away if/when Guile is
converted to use OS-level threads.

I guess the technique Mikael used for basic I/O could be applied here
too, although I'm not sure how reliable/portable it is to use select
to wait for connections.

By the way, I was impressed that someone with an address of
crayc@206.31.63.15 could get a message out to the cygnus lists.  I've
had messages rejected for seemingly lesser crimes.

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