[Top][All Lists]
[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: |
Tue, 19 Feb 2002 22:33:02 +0100 |
address@hidden wrote:
> This is a useful feature, and a clean Lisp interface.
> I see a couple of possible gaps in the implementation, though.
>
> Doing this from Emacs itself is cleaner than running an actual
> subprocess like emacsserver to do the job. But the subprocess runs
> all the time, in parallel with Emacs, while this code seems to be able
> to accept a server connection only inside wait_reading_process_input.
> If Emacs is running a Lisp program for a long time, it may go for a
> long time without ever calling wait_reading_process_input. This could
> conceivably mean that Emacs takes too long to respond and the request
> fails.
>
> Can you make connection acceptance happen in response to a signal
> such as SIGIO, or make it happen in an alarm that happens frequently?
> (Such as the one used to poll for available terminal input.)
> The actual running of the filter function would have to wait until
> wait_reading_process_input, of course. Something like this already
> happens with sentinels, I recall.
I think this is not necessary. Connection requests are queued by the
OS; accept just takes the first established connection out of the
queue. A request only fails if the queue is already full.
> One other point: this seems to be designed to work with PF_INET
> sockets only. If you look at emacsclient, you'll see it uses either a
> PF_UNIX socket or SYSVIPC. To make server sockets replace
> emacsserver, they would have to support both PF_UNIX sockets and
> SYSVIPC (unless SYSVIPC is obsolete nowadays and all systems support
> sockets).
I modified the code to work with Unix domain sockets.
open-server-socket takes now 3 arguments: NAME, PROTOCOL and
PORT-OR-PATHNAME. Protocol is either 'inet or 'unix.
Supporting SYSVIPC would be a lot of work, because SYSVIPC uses a
different API, e.g. msgrcv/msgsnd where sockets use read/write. I
think SYSVIPC is not worth the trouble.
Helmut.