unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: helmut@212186011228.11.tuwien.teleweb.at
Subject: Re: New patch for server sockets and datagram (UDP) support.
Date: 07 Mar 2002 11:56:25 +0100	[thread overview]
Message-ID: <5xg03cprxi.fsf@kfs2.cua.dk> (raw)
In-Reply-To: <5xofi1p7cz.fsf_-_@kfs2.cua.dk>

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 <storm@cua.dk> http://www.cua.dk


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


  reply	other threads:[~2002-03-07 10:56 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m2u1sa7819.fsf@xaital.online-marketwatch.com>
2002-02-21 23:45 ` Non-blocking open-network-stream Kim F. Storm
2002-02-22 16:04   ` Stefan Monnier
2002-02-25 22:38   ` Kim F. Storm
2002-02-26 22:46     ` Helmut Eller
2002-02-27 11:59       ` Kim F. Storm
2002-02-28  4:08         ` Richard Stallman
2002-03-01  0:21           ` Kim F. Storm
2002-03-01  8:01             ` Juanma Barranquero
2002-03-01 10:50               ` Kim F. Storm
2002-03-01 17:10                 ` Pavel Janík
2002-03-01 21:23             ` Richard Stallman
2002-03-07  0:08               ` New patch for server sockets and datagram (UDP) support Kim F. Storm
2002-03-07 10:56                 ` Kim F. Storm [this message]
2002-03-07 11:39                   ` Alex Schroeder
2002-03-07 12:39                     ` Kim F. Storm
2002-03-07 14:51                       ` Alex Schroeder
2002-03-08 21:06                       ` Richard Stallman
2002-03-13 15:56                         ` Kim F. Storm
2002-03-13 23:19                           ` Final(?) " Kim F. Storm
2002-03-14  0:50                             ` Al Petrofsky
2002-03-14  9:30                               ` Kim F. Storm
2002-03-14 12:42                               ` Richard Stallman
2002-03-14 13:35                                 ` Kim F. Storm
2002-03-17 22:02                             ` I have installed the " Kim F. Storm
2002-03-07 15:18                   ` New " Helmut Eller
2002-03-07 16:09                     ` Kim F. Storm
2002-03-07 17:32                       ` Helmut Eller
2002-03-07 23:58                         ` Kim F. Storm
2002-03-08  7:38                           ` Helmut Eller
2002-03-08  9:13                             ` Kim F. Storm
2002-03-08 11:16                               ` Helmut Eller
2002-03-08 16:36                               ` Stefan Monnier
2002-03-08 20:57                                 ` Kim F. Storm
2002-03-08 21:03                                   ` Stefan Monnier
2002-03-08 21:07                             ` Richard Stallman
2002-03-13 15:12                               ` Kim F. Storm
2002-03-07 12:54                 ` Mario Lang
2002-03-07 12:58                   ` Kim F. Storm
2002-03-08  9:09                 ` Richard Stallman
2002-03-08  9:35                   ` Kim F. Storm
2002-03-08 11:04                   ` Helmut Eller
2002-03-02  7:59             ` Non-blocking open-network-stream Helmut Eller
2002-03-03  0:12               ` Kim F. Storm
2002-03-03 10:46                 ` Helmut Eller
2002-03-03 16:44                 ` Mario Lang
2002-03-03 14:39               ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=5xg03cprxi.fsf@kfs2.cua.dk \
    --to=storm@cua.dk \
    --cc=helmut@212186011228.11.tuwien.teleweb.at \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).