emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [feature request] SOCK_SEQPACKET


From: Stefan Monnier
Subject: Re: [feature request] SOCK_SEQPACKET
Date: Tue, 24 Nov 2009 15:35:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

> 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);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]