From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [feature request] SOCK_SEQPACKET Date: Tue, 24 Nov 2009 15:35:09 -0500 Message-ID: References: <2e0e1cd40911232205g5a929ebdgd946f88afa3ecbd9@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259095022 1518 80.91.229.12 (24 Nov 2009 20:37:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Nov 2009 20:37:02 +0000 (UTC) Cc: emacs-devel@gnu.org To: Daniel Hackney Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 24 21:36:55 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 1ND285-0002Jj-AT for ged-emacs-devel@m.gmane.org; Tue, 24 Nov 2009 21:36:53 +0100 Original-Received: from localhost ([127.0.0.1]:60049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ND284-0005Sf-Q6 for ged-emacs-devel@m.gmane.org; Tue, 24 Nov 2009 15:36:52 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ND27y-0005R0-QM for emacs-devel@gnu.org; Tue, 24 Nov 2009 15:36:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ND27t-0005Od-Bl for emacs-devel@gnu.org; Tue, 24 Nov 2009 15:36:45 -0500 Original-Received: from [199.232.76.173] (port=39124 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ND27t-0005Oa-8Y for emacs-devel@gnu.org; Tue, 24 Nov 2009 15:36:41 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:39601) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ND27t-0003x7-2h for emacs-devel@gnu.org; Tue, 24 Nov 2009 15:36:41 -0500 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id nAOKZ9MN008783; Tue, 24 Nov 2009 15:35:09 -0500 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 633BF3A1B6; Tue, 24 Nov 2009 15:35:09 -0500 (EST) In-Reply-To: <2e0e1cd40911232205g5a929ebdgd946f88afa3ecbd9@mail.gmail.com> (Daniel Hackney's message of "Tue, 24 Nov 2009 01:05:24 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3413=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:117705 Archived-At: > I'm currently working on Ezbl [1], an Emacs interface for the Uzbl [2] > web browser, and have hit a bit of a hitch. Uzbl communicates over a > socket connection using the SOCK_SEQPACKET socket type. I think they did > this because it preserves record boundaries, as opposed to > SOCK_STREAM. Regardless, I noticed that Emacs can't use the > SOCK_SEQPACKET type. > It doesn't seem like SOCK_SEQPACKET is used much, but it would be nice > to have, if only for completeness sake. I don't really know any C-level > Emacs programming (I'm pretty comfortable with Elisp), but I would be > willing to help out however I can if given some guidance and an overview > of what would need to be done. You can start with the patch below (guaranteed 100% untested). I know nothing about SOCK_SEQPACKET, other than what I just read in the manpage of `socket', so this code probably doesn't do the right thing. The main problem I'd except would have to do with the fact that Emacs will typically read and write in blocks of fixed size (like 1KB or 4KB maybe, IIRC), so for packets smaller than that size it might work fine, but for larger packets you may end up having to make more substantial changes. Stefan === modified file 'src/process.c' --- src/process.c 2009-11-24 15:30:54 +0000 +++ src/process.c 2009-11-24 20:30:20 +0000 @@ -127,7 +127,7 @@ Lisp_Object Qprocessp; Lisp_Object Qrun, Qstop, Qsignal; Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; -Lisp_Object Qlocal, Qipv4, Qdatagram; +Lisp_Object Qlocal, Qipv4, Qdatagram, Qseqpacket; Lisp_Object Qreal, Qnetwork, Qserial; #ifdef AF_INET6 Lisp_Object Qipv6; @@ -253,6 +253,10 @@ #endif /* DATAGRAM_SOCKETS */ #endif /* BROKEN_DATAGRAM_SOCKETS */ +#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS +# define HAVE_SEQPACKET +#endif + #if !defined (ADAPTIVE_READ_BUFFERING) && !defined (NO_ADAPTIVE_READ_BUFFERING) #ifdef EMACS_HAS_USECS #define ADAPTIVE_READ_BUFFERING @@ -3299,6 +3303,10 @@ else if (EQ (tem, Qdatagram)) socktype = SOCK_DGRAM; #endif +#ifdef HAVE_SEQPACKET + else if (EQ (tem, Qseqpacket)) + socktype = SOCK_SEQPACKET; +#endif else error ("Unsupported connection type"); @@ -7330,10 +7338,12 @@ #ifdef DATAGRAM_SOCKETS ADD_SUBFEATURE (QCtype, Qdatagram); #endif +#ifdef HAVE_SEQPACKET + ADD_SUBFEATURE (QCtype, Qseqpacket); +#endif #ifdef HAVE_LOCAL_SOCKETS ADD_SUBFEATURE (QCfamily, Qlocal); #endif - ADD_SUBFEATURE (QCfamily, Qipv4); #ifdef AF_INET6 ADD_SUBFEATURE (QCfamily, Qipv6); #endif @@ -7403,6 +7413,8 @@ #endif Qdatagram = intern_c_string ("datagram"); staticpro (&Qdatagram); + Qseqpacket = intern_c_string ("seqpacket"); + staticpro (&Qseqpacket); QCport = intern_c_string (":port"); staticpro (&QCport);