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: select+read on socket in gtk,guile-gtk


> Date: Mon, 19 Jun 2000 23:16:50 -0400 (EDT)
> From: Steve Tell <tell@telltronics.org>
> 
> Does guile-gtk provide a way to hook (file descriptors from) guile ports
> into the Gtk+ select loop?   Glib's GIOChannel's perhaps?
> I know I could fall back on gtk-idle-add, but it seems less clean.

I don't know anything about this.

> Next question then is, how do I do a non-blocking read on a guile port,
> returning as many characters as are available right now?  Is there an
> interface to the raw read(2) system call, like perl's sysread()?

There's no sysread procedure for ports in general, but recv! and 
recvfrom! can be used on socket ports.

A general sysread seems like a reasonable thing to want.  It probably
needs to be implemented as a member of the ptob structure, so that it
can work as expected for unbuffered ports.

To avoid blocking when no bytes are available at all, you'd also need
to put the port into non-blocking mode:

(define p (pipe))
(define pr (car p))
(fcntl pr F_SETFL (logior O_NONBLOCK (fcntl pr F_GETFL)))

(read-char pr) =>

standard input:7:1: In procedure read-char in expression (read-char (car p)):
standard input:7:1: Resource temporarily unavailable
ABORT: (system-error)

> What I'm ultimately trying to do is arrange for a procedure to get called
> with complete lines read from a connected TCP socket, so that information
> recieved from the server at the other end can be used to update a
> items in a guile-gtk interface.

read-line or read-delimited could probably do it, but would block.

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