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: Input/output problems with closed ports


>>>>> "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

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