From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Hackney Newsgroups: gmane.emacs.devel Subject: Re: [feature request] SOCK_SEQPACKET Date: Thu, 3 Dec 2009 16:23:32 -0500 Message-ID: <2e0e1cd40912031323m4f69bc5bq73ee0b6178d2ae21@mail.gmail.com> References: <2e0e1cd40911232205g5a929ebdgd946f88afa3ecbd9@mail.gmail.com> <2e0e1cd40911241317w487d85eds4826f71cd46ab1b4@mail.gmail.com> <2e0e1cd40912030004m81c4cabq3cce18b60f124ae8@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1259879162 9654 80.91.229.12 (3 Dec 2009 22:26:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 3 Dec 2009 22:26:02 +0000 (UTC) Cc: Simon Leinen , emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 03 23:25:54 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NGK7J-0003T9-U7 for ged-emacs-devel@m.gmane.org; Thu, 03 Dec 2009 23:25:42 +0100 Original-Received: from localhost ([127.0.0.1]:50152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGK7J-00068h-Jo for ged-emacs-devel@m.gmane.org; Thu, 03 Dec 2009 17:25:41 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGJ9I-00060V-ND for emacs-devel@gnu.org; Thu, 03 Dec 2009 16:23:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGJ9E-0005xH-OB for emacs-devel@gnu.org; Thu, 03 Dec 2009 16:23:40 -0500 Original-Received: from [199.232.76.173] (port=46511 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGJ9E-0005x9-Je for emacs-devel@gnu.org; Thu, 03 Dec 2009 16:23:36 -0500 Original-Received: from fg-out-1718.google.com ([72.14.220.159]:1938) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NGJ9E-00056V-7a for emacs-devel@gnu.org; Thu, 03 Dec 2009 16:23:36 -0500 Original-Received: by fg-out-1718.google.com with SMTP id l26so191480fgb.12 for ; Thu, 03 Dec 2009 13:23:35 -0800 (PST) Original-Received: by 10.102.13.19 with SMTP id 19mr741260mum.13.1259875414853; Thu, 03 Dec 2009 13:23:34 -0800 (PST) Original-Received: from mail-bw0-f215.google.com (mail-bw0-f215.google.com [209.85.218.215]) by mx.google.com with ESMTPS id u26sm6624689mug.15.2009.12.03.13.23.33 (version=SSLv3 cipher=RC4-MD5); Thu, 03 Dec 2009 13:23:34 -0800 (PST) Original-Received: by bwz7 with SMTP id 7so1624284bwz.26 for ; Thu, 03 Dec 2009 13:23:33 -0800 (PST) Original-Received: by 10.204.24.83 with SMTP id u19mr2339513bkb.22.1259875412375; Thu, 03 Dec 2009 13:23:32 -0800 (PST) In-Reply-To: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-Mailman-Approved-At: Thu, 03 Dec 2009 17:05:45 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:118212 Archived-At: Stefan Monnier wrote: >> At any rate, it looks like supporting SOCK_SEQPACKET over AF_UNIX >> wouldn't be that bad (I've basically got it working), so it might be >> worth cleaning that up for inclusion and waiting to see if anyone >> with the proper knowledge wants to come along and add SCTP support to >> Emacs. > > Emacs hasn't been at the forefront of the networking technology, and I > don't see why that should change, so SEQPACKET with AF_UNIX is > perfectly sufficient. Well, from an "I want ponies" perspective, it would be great if Emacs supported every network type :) > If/when someone needs SEQPACKET over AF_INET, we may then consider > whether and how to add support for it. Plus, it looks like there are issues with underlying OS support, so it's out of our hands for now. >> By the way, there were a few changes that needed to be made in order >> to allow creating AF_UNIX SOCK_SEQPACKET servers, basically replacing >> "socktype == SOCK_STREAM" with "socktype == SOCK_STREAM || socktype >> == SOCK_SEQPACKET". I've attached a patch (to be applied after Stefan >> Monnier's previous patch) which takes care of this. > > That's all? With my patch plus yours, it works? Yup. I have cookies flowing brilliantly between Emacs and Uzbl, and simple scripts connect just like they should. > The mind boggles (I never wrote any networking code, so my patch was > really just an "educated guess" based on the existing code and the > manpage). Same here. The nice thing is that it seems like SOCK_SEQPACKET can be used basically the same as SOCK_STREAM, but with some additional funky stuff (as well as using SCTP when done of AF_INET). The only thing to consider now would be to try to take advantage of SOCK_SEQPACKET's record delimiters, which are exposed through recvmsg(2) and sendmsg(2) and the struct msghdr. This would allow for record delimiting at the socket layer, potentially making certain kinds of operations easier. Without having looked at it, it seems like emacsclient could benefit from record delimiters, as each command sent over the socket could be delimited by a MSG_EOR, reducing the need for dealing with delimiting records at the application layer. I'll start to take a look at this, but it may be more effort than it's worth, because of the limited AF support for SOCK_SEQPACKET. It looks like, at a minimum, we would have to replace the calls to emacs_read/write() with sendmsg()/recvmsg(). Also we would need to think about how to deal with MSG_EOR in the context of reading into a buffer. There isn't any change to the stream, but certain calls to recvmsg(2) would include a MSG_EOR with them. Off the top of my head, it seems like we could call the process sentinel when MSG_EOR is encountered. Looking at the info page for sentinels, it looks like there could be a chance that the sentinel might miss two MSG_EORs if they are encountered in quick succession, though I could be wrong about this. Anyway, I'm mainly thinking out loud here, let me know if I'm entirely crazy :) -- Daniel M. Hackney