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]

sockets are not really ports?


Hi

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've tried looking into socket.c, and this is what I find:

SCM 
scm_set_current_input_port (SCM port)
{
  SCM oinp = scm_cur_inp;
  SCM_ASSERT (SCM_NIMP (port) && SCM_OPINPORTP (port), port, SCM_ARG1, s_set_current_input_port);
  scm_cur_inp = port;
  return oinp;
}

I'm guessing the SCM_OPINPORTP test is failing, so I look at ports.h, and see:

#define SCM_OPINPORTP(x) (((0x7f | SCM_OPN | SCM_RDNG) & SCM_CAR(x))==(scm_tc7_port | SCM_OPN | SCM_RDNG))

As far as I can tell, it's checking that the port is open and
readable, which it is. A socket port is mostly created by just calling
scm_fdes_to_port() on the result of accept()... so something is going
on that I don't see.

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