emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature suggestion: server sockets


From: Helmut Eller
Subject: Re: Feature suggestion: server sockets
Date: Mon, 18 Feb 2002 19:26:49 +0100

address@hidden (Kim F. Storm) wrote: 

>
> This sounds like a useful addition to me.

Nice to hear.

> I am currently working on a different aspect of network support
> (optionally making open-network-stream non-blocking), and I have
> modified open-network-stream to take two optional arguments:
>         FILTER and SENTINEL
> to set the process filter and sentinel as part of opening the
> network stream (to avoid race conditions).  The SENTINEL is
> called when the connect completes (either in success or failure).
> 
> I suspect that your proposal for open-server-socket could similarly
> have the FILTER and SENTINEL functions as arguments.  Then I don't see
> any need for your accept-connection function as SENTINEL could be
> called when a new connection is accepted, and the FILTER could be used
> as a normal filter (processing received data) for the connection.
>
> If you don't want to accept more connections on the server-socket,
> it should be closed in the sentinel.

Yes, this is certainly possible.

But what is the advantage of not having accept-connection?

The behavior you describe can easily be implemented at the Lisp level
when you have accept-connection.  I choose to use two functions
because I think this is (slightly) more flexible.  When I have a
choice, I prefer having more low-level functions, than having fewer
high-level functions.  The high-level functions can be implemented in
terms of the lower level functions; the reverse is not possible.

If you are concerned about race conditions: open-server-socket is
blocking, so no danger here.  I'm not sure, but doing wired things
with accept-connection in combination with accept-process-output (like
nested calls to accept-process-output in filters) can result in
"unexpected behaviour".  This is more a problem of my implementation
than of the interface.  Your proposal is safer in this respect,
because one can not even do this wired things.  But again, if you want
a fool-proof interface, provide it as Lisp wrapper.

I think this are mostly style questions.  If you prefer a single
function I have no problem with that.

Regards,
Helmut.












reply via email to

[Prev in Thread] Current Thread [Next in Thread]