all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Daniel Hackney <dan@haxney.org>
To: Simon Leinen <simon.leinen@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [feature request] SOCK_SEQPACKET
Date: Thu, 3 Dec 2009 03:04:56 -0500	[thread overview]
Message-ID: <2e0e1cd40912030004m81c4cabq3cce18b60f124ae8@mail.gmail.com> (raw)
In-Reply-To: <d4bdfcb00911250553l25b89292q96b6574f7995c383@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2749 bytes --]

Simon Leinen <simon.leinen@gmail.com> wrote:
>> I'm in pretty much the same boat, as I had never even heard of
>> SOCK_SEQPACKET until I saw that Uzbl uses it. I'll hack on it a bit
>> to test it and make sure it works, but you'll probably want someone
>> with legitimate socket knowledge (i.e. not me ;) to review it before
>> committing anything I turn out.
>
> I probably won't have the time or expertise to review this.

No worries; it seems like SOCK_SEQPACKET is pretty obscure, so not many
people have used it much.

> SOCK_SEQPACKET will select SCTP, which is an alternative transport
> protocol to TCP. It preserves message boundaries and has many other
> features over TCP. [...]

Yikes, I'd hate to have to deal with that! The one nice thing is that it
looks like for Unix sockets, SCTP isn't used, and I was able to
successfully send some data back and forth between Emacs and Python over
a local SOCK_SEQPACKET.

Another complication is that the Linux socket(2) manpage says:

  Some socket types may not be implemented by all protocol families; for
  example, SOCK_SEQPACKET is not implemented for AF_INET.

So we may be kind of out of luck on that front. I'll look into it a bit
more, but it looks like there isn't going to be much we can do about
that without hacking on the kernel or glibc (which I have no intention
of doing :).

> It would probably be a win if Emacs had SCTP support for those who
> need that, if that set of people has a non-empty intersection with the
> set of Emacs users.  The sockets API for SCTP seems to be
> unfinished/in flux - the Internet-Draft
> (http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket) seems to have
> expired right now.

From what I hear, SCTP has some nice semantics, but requires new calls
and fancy stuff which is way beyond my ability.

> It is also 85 pages long.

Ahhhh!!!

> We probably wouldn't want to support all of SCTP's features.  The
> difficulty may be to find out what are the basic useful features that
> make people want to use SCTP rather than TCP...

Not really anything I can do to help there, as I'm pretty much a network
newbie.

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.

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.

--
Daniel M. Hackney

[-- Attachment #2: commit-373bef0 --]
[-- Type: application/octet-stream, Size: 2005 bytes --]

commit 373bef0db55c5055a3a1086585c4cb17a73e56e0
Author: Dan Hackney <dan@haxney.org>
Date:   Thu Dec 3 02:29:20 2009 -0500

    Allow listening on sockets with SOCK_SEQPACKET.
    
    Does not take into account any of the semantic differences between
    SOCK_STREAM and SOCK_SEQPACKET, merely changes checks for "socktype ==
    SOCK_STREAM" to checks for SOCK_STREAM or SOCK_SEQPACKET.
    
    Signed-off-by: Dan Hackney <dan@haxney.org>

diff --git a/src/process.c b/src/process.c
index 2cce741..8186af7 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3328,7 +3328,7 @@ usage: (make-network-process &rest ARGS)  */)
   QCaddress = is_server ? QClocal : QCremote;
 
   /* :nowait BOOL */
-  if (!is_server && socktype == SOCK_STREAM
+  if (!is_server && (socktype == SOCK_STREAM || socktype == SOCK_SEQPACKET)
       && (tem = Fplist_get (contact, QCnowait), !NILP (tem)))
     {
 #ifndef NON_BLOCKING_CONNECT
@@ -3423,7 +3423,7 @@ usage: (make-network-process &rest ARGS)  */)
      Some kernels have a bug which causes retrying connect to fail
      after a connect.  Polling can interfere with gethostbyname too.  */
 #ifdef POLL_FOR_INPUT
-  if (socktype == SOCK_STREAM)
+  if (socktype == SOCK_STREAM || socktype == SOCK_SEQPACKET)
     {
       record_unwind_protect (unwind_stop_other_atimers, Qnil);
       bind_polling_period (10);
@@ -3626,7 +3626,7 @@ usage: (make-network-process &rest ARGS)  */)
 	    }
 #endif
 
-	  if (socktype == SOCK_STREAM && listen (s, backlog))
+	  if ((socktype == SOCK_STREAM || socktype == SOCK_SEQPACKET) && listen (s, backlog))
 	    report_file_error ("Cannot listen on server socket", Qnil);
 
 	  break;
@@ -3789,7 +3789,7 @@ usage: (make-network-process &rest ARGS)  */)
   p->pid = 0;
   p->infd  = inch;
   p->outfd = outch;
-  if (is_server && socktype == SOCK_STREAM)
+  if (is_server && (socktype == SOCK_STREAM || socktype == SOCK_SEQPACKET))
     p->status = Qlisten;
 
   /* Make the process marker point into the process buffer (if any).  */

  parent reply	other threads:[~2009-12-03  8:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-24  6:05 [feature request] SOCK_SEQPACKET Daniel Hackney
2009-11-24 20:35 ` Stefan Monnier
2009-11-24 21:17   ` Daniel Hackney
     [not found]     ` <d4bdfcb00911250553l25b89292q96b6574f7995c383@mail.gmail.com>
2009-12-03  8:04       ` Daniel Hackney [this message]
2009-12-03 18:51         ` Stefan Monnier
2009-12-03 21:23           ` Daniel Hackney
2009-12-04  1:50             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2e0e1cd40912030004m81c4cabq3cce18b60f124ae8@mail.gmail.com \
    --to=dan@haxney.org \
    --cc=emacs-devel@gnu.org \
    --cc=simon.leinen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.