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: Bernard dot Urban at meteo dot fr
- Subject: Re: Input/output problems with closed ports
- From: Gary Houston <ghouston at freewire dot co dot uk>
- Date: 2 Dec 1999 14:36:19 -0000
- 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>
| Yes. Actually, the situation is the following: I have a select() which
| monitors stdin and some socket p. These 2 ports have each a handler
| (say a repl for stdin). If you receive some special data on
| p, the handler for p closes the socket port.
| The repl on stdin is still there, with
| object p available, and you want to write safely to p from the repl.
|
| I can even be more specific: p is a connection to a remote X11 server,
| and the special data is the X event
| send when someone on the remote side clicks the "Quit" button.
| Writing to p from the repl would be asking for creating a new window.
| The role of "close?" is to be sure if this is legitimate.
I'm not entirely convinced, but there's probably no good reason not to
add the procedure. You can do it like this anyway:
(define (closed? port)
(let ((str (with-output-to-string (lambda () (write port)))))
(string=? (substring str 2 8) "closed")))