This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Input/output problems with closed ports
- To: Gary Houston <ghouston at freewire dot co dot uk>
- Subject: Re: Input/output problems with closed ports
- From: Bernard URBAN <Bernard dot Urban at meteo dot fr>
- Date: 03 Dec 1999 19:40:41 +0100
- Cc: guile at sourceware dot cygnus dot com
- References: <9911301212.AA29152@min.meteo.fr> <19991130223429.9221.qmail@ghouston.freewire.co.uk> <yg1ogcbouft.fsf@min.meteo.fr> <19991202143619.948.qmail@ghouston.freewire.co.uk>
>>>>> "Gary" == Gary Houston <ghouston@freewire.co.uk> writes:
Gary> | Yes. Actually, the situation is the following: I have a
Gary> select() which | monitors stdin and some socket p. These 2
Gary> ports have each a handler | (say a repl for stdin). If you
Gary> receive some special data on | p, the handler for p closes
Gary> the socket port. | The repl on stdin is still there, with |
Gary> object p available, and you want to write safely to p from
Gary> the repl. | | I can even be more specific: p is a
Gary> connection to a remote X11 server, | and the special data is
Gary> the X event | send when someone on the remote side clicks
Gary> the "Quit" button. | Writing to p from the repl would be
Gary> asking for creating a new window. | The role of "close?" is
Gary> to be sure if this is legitimate.
Gary> I'm not entirely convinced, but there's probably no good
Gary> reason not to add the procedure. You can do it like this
Gary> anyway:
Gary> (define (closed? port) (let ((str (with-output-to-string
Gary> (lambda () (write port))))) (string=? (substring str 2 8)
Gary> "closed")))
It seems to me too dependent on the external representation of ports
in Guile. I would better go for some encapsulation of a close/open
state with GOOPS.
Regards.
--
B. Urban