From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.help Subject: Re: How to communicate with a running external process with Date: Tue, 23 Jul 2013 11:30:37 +0200 Message-ID: <87haflr5c2.fsf@gmail.com> References: <7DEC2F40B9E0874681480168A47FD3C11AF1E5E6@MSGPEXCEI32B.mfad.mfroot.org> <87txjlr9js.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1374571878 27921 80.91.229.3 (23 Jul 2013 09:31:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Jul 2013 09:31:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 23 11:31:20 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V1YwA-0005fO-5K for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Jul 2013 11:31:18 +0200 Original-Received: from localhost ([::1]:60845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Yw9-00061Q-O0 for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Jul 2013 05:31:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Yvq-0005x2-Ip for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 05:31:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1Yvp-0008BL-3M for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 05:30:58 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:51245) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Yvo-0008B8-T7 for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 05:30:57 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V1Yvk-0005AR-Fx for help-gnu-emacs@gnu.org; Tue, 23 Jul 2013 11:30:52 +0200 Original-Received: from g231105110.adsl.alicedsl.de ([92.231.105.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Jul 2013 11:30:52 +0200 Original-Received: from tjolitz by g231105110.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Jul 2013 11:30:52 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 46 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g231105110.adsl.alicedsl.de User-Agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:/VWpL++nuF0QxTxZVsfjwBLUgro= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92344 Archived-At: Yuri Khan writes: > On Tue, Jul 23, 2013 at 2:59 PM, Thorsten Jolitz wrote: > >> Assume there are 2 otherLisp processes up and running and 2 Emacs >> processes, and you want to communicate from otherLisp with PID 5555 to >> Emacs with PID 6666. > > First, decide which program is the server and which is the client. A > server, roughly speaking, is the process that first establishes the > channel of communication — creates a pipe, a Unix socket, or listens > on a TCP port. Clients then have to know the pipe path/filename, the > Unix socket path, or the IP address and TCP port, in order to connect > to the server. Once the connection by client is established, both > server and client have a file descriptor and can communicate just by > writing into it. > > If you have two instances of the server, they have to listen on > different pipes, Unix sockets (by path/name), or, in case of TCP, the > pairs have to be distinct. Thus, the clients will be > able to connect to the server they want, by knowing the specific > server pipe or Unix socket path or IP address and TCP port. > > The process ID just never enters the picture. (Although, if you > control the server, you can make up a convention that, e.g., the > server always listens on the Unix socket with the path > /var/run/your_server_name.$PID.) ok, I think now I get it - just like starting a TCP server and then accessing its , the otherLisp (as a server) has to open a pipe or socket first (which do have a path/filename), and knowing the path/filename I can access that otherLisp process that acts as a server from an Emacs Lisp program. Vice versa it should be possible to open a pipe or socket from Emacs Lisp (without starting a subprocess of otherLisp), and connect to it from otherLisp using the specific path/filename. I think I have to take a second look at the manuals wrt this idea. So in both Lisp dialect there should be a way to open a pipe or socket, return the path/filename of it, and keep listening for incoming connections until it is closed. Thanks for the tips. -- cheers, Thorsten