From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: New patch for server sockets and datagram (UDP) support. Date: 07 Mar 2002 11:56:25 +0100 Message-ID: <5xg03cprxi.fsf@kfs2.cua.dk> References: <5xwux64cxe.fsf@kfs2.cua.dk> <5xg03pyyo3.fsf@kfs2.cua.dk> <5xadtvuodz.fsf@kfs2.cua.dk> <200202280408.g1S48QG19264@aztec.santafe.edu> <5xvgchkui4.fsf@kfs2.cua.dk> <200203012123.g21LNvS20494@aztec.santafe.edu> <5xofi1p7cz.fsf_-_@kfs2.cua.dk> NNTP-Posting-Host: quimby2.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: quimby2.netfonds.no 1015499100 5843 195.204.10.66 (7 Mar 2002 11:05:00 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 7 Mar 2002 11:05:00 GMT Cc: helmut@212186011228.11.tuwien.teleweb.at Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby2.netfonds.no with esmtp (Exim 3.12 #1 (Debian)) id 16ivhj-0001W9-00 for ; Thu, 07 Mar 2002 12:04:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16ivaF-0002Ze-00; Thu, 07 Mar 2002 05:57:15 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by fencepost.gnu.org with smtp (Exim 3.33 #1 (Debian)) id 16ivYS-0002Tk-00 for ; Thu, 07 Mar 2002 05:55:24 -0500 Original-Received: from kfs2.cua.dk.cua.dk (kfs2.local.filanet.dk [192.168.1.182]) by mail.filanet.dk (Postfix) with SMTP id 5AAD27C047; Thu, 7 Mar 2002 10:55:22 +0000 (GMT) Original-To: emacs-devel@gnu.org In-Reply-To: <5xofi1p7cz.fsf_-_@kfs2.cua.dk> Original-Lines: 119 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: quimby.gnus.org gmane.emacs.devel:1776 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1776 I wrote: > The following patch adds server socket support via open-network-stream. > If the HOST is nil, a server socket for SERVICE is opened in listening > state. > I forgot to say, that the code is working nicely, but the patch is still "work in progress" to let you know how this is progressing and get your comments on the direction it is taking. > I have removed the NON-BLOCKING argument, and instead added a new TYPE > argument, which specifies the type of connection (blocking connect, > non-blocking connect, or datagram), and may optionally specify the > address family (inet or local [aka. unix]). Actually, I would like to get rid of this extra TYPE argument all together by modifying the HOST and SERVICE arguments in a backwards compatible way (when calling open-network-stream): When the HOST and SERVICE are specified as "simple" arguments (strings or integer port number), a TCP/IP connection is created using a blocking connect. To get a non-blocking TCP connect, or a datagram socket, the SERVICE argument is a cons (TYPE . SERVICE), where TYPE is t for a non-blocking connect, and `datagram' for a datagram socket. Likewise, to use another address/protocol family than IP, the HOST argument is a cons (FAMILY . HOST), where FAMILY is `local' for a local (aka UNIX) socket. Also, I think that HOST should be t to get a server socket rather than nil. This is because, for a local (UNIX) socket, there is no hostname, so the hostname would logically be nil for a client. However, there is one problem with this approach: The value returned from `process-contact' for a network stream is specified to be (HOST SERVICE) -- which my patch modifies to (HOST SERVICE TYPE FILTER SENTINEL). The only use I've found for process-contact is in the clone-process function where it is obviously assumed to return the parameters originally given to open-network-stream (thus the change). Now, if I want to get rid of TYPE by modifing the possible arguments for HOST and SERVICE, this would obviously have to be reflected in the value returned by process-contact as well. So if code currently exists which expects (car (process-contact p)) or (cadr (process-contact p)) to return the hostname or service, that code will fail after the change. But I haven't found any such code though -- do you know of any code using process-contact? My suggestion is to change `process-contact' to do the following: For a network conntecton, the value is a list (HOST SERVICE FILTER SENTINEL) with the same format as the corresponding arguments to `open-network-stream'. The current doc string says: For a net connection, the value is a cons cell of the form (HOST SERVICE). Below you can see the difference between using the TYPE argument and encoding the information in the HOST and SERVICE args (and using HOST=t for a server socket). > > To open a TCP server socket for "telnet", where client > processes have no buffer, do > > (open-network-stream "telnetd" nil nil "telnet" nil > telnetd-filter telnetd-sentinel) (open-network-stream "telnetd" nil t "telnet" telnetd-filter telnetd-sentinel) > > To open a UDP (datagram) server socket for "dns", do > > (open-network-stream "dns" nil nil "dns" 'datagram > dns-filter dns-sentinel) (open-network-stream "dns" nil t '(datagram . "dns") dns-filter dns-sentinel) > > To open a LOCAL (UNIX) server socket for "/tmp/xyz", where > client processes do have a buffer, do > > (open-network-stream "xyz" "XYZ" nil "/tmp/xyz" '(local) > xyz-filter xyz-sentinel) (open-network-stream "xyz" "XYZ" '(local . t) "/tmp/xyz" xyz-filter xyz-sentinel) To connect to each of these services, specify the hostname (or nil for a local socket) instead of t in the third argument (and modify other parameters according to the desired use), e.g. ;; non-blocking connect, use buffer, no filter (open-network-stream "telnet" "TELNET" "hostname" '(t . "telnet") nil telnet-client-sentinel) ;; datagram "connect", no buffer, use filter (open-network-stream "dns" nil "hostname" '(datagram . "dns") dns-filter dns-sentinel) ;; local socket, non-blocking connect, use buffer, no filter (open-network-stream "xyz" "XYZ" '(local) '(t . "/tmp/xyz") nil xyz-sentinel) What do you think? -- Kim F. Storm http://www.cua.dk _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel