Debug message fix
[sxemacs] / lisp / multicast.el
1 ;;; multicast.el --- lisp frontend for multicast connections in SXEmacs
2
3 ;; Copyright (C) 1997-2000 Didier Verna.
4
5 ;; Author:          Didier Verna <didier@xemacs.org>
6 ;; Maintainer:      Didier Verna <didier@xemacs.org>
7 ;; Created:         Thu Dec  4 16:37:39 1997
8 ;; Last Revision:   Mon Jan 19 19:10:50 1998
9 ;; Current Version: 0.4
10 ;; Keywords:        dumped comm processes
11
12 ;; This file is part of SXEmacs.
13
14 ;; SXEmacs is free software: you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
18
19 ;; SXEmacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
26
27
28 ;;; Commentary:
29
30 ;; This file just contains a lisp frontend to the internal function
31 ;; open-multicast-group-internal written in C and belonging to process.c
32 ;; Well, nothing much to say about it ... read the doc string.
33
34
35 ;;; Change Log:
36
37 ;; Rev. of Mon Jan 19 19:04:44 1998 : packaging cleanup
38 ;; Rev. of Thu Dec 11 13:54:26 1997 : updated the docstring
39 ;; Rev. of Mon Dec  8 15:28:47 1997 : Improved the doc string
40 ;; Rev. of Thu Dec  4 16:38:09 1997 : Initial Version.
41
42
43 ;;; Code:
44
45 (defun open-multicast-group (name buffer address)
46   "Open a multicast connection on the specified address.
47 Returns a process object to represent the connection.
48 Input and output work as for subprocesses; `delete-process' closes it.
49 Args are NAME BUFFER ADDRESS.
50 NAME is a name for the process. It is modified if necessary to make it unique.
51 BUFFER is the buffer (or buffer-name) to associate with the process.
52  Process output goes at the end of that buffer, unless you specify an output
53  stream or filter function to handle the output.
54  BUFFER may be also nil, meaning that this process is not associated with any
55  buffer
56 ADDRESS specifies a standard multicast address \"dest/port/ttl\":
57  dest is an internet address between 224.0.0.0 and 239.255.255.255
58  port is a communication port like in traditional unicast
59  ttl is the time-to-live (15 for site, 63 for region and 127 for world).
60
61 WARNING: it is *strongly* recommended to avoid using groups beginning with
62          224 or 239. Such groups are considered 'admin' groups, and may
63          behave in a surprising way ..."
64   (let (dest port ttl)
65     ;; We check only the general form of the multicast address.
66     ;; The rest will be handled by the internal function.
67     (string-match #r"^\([0-9\.]+\)/\([0-9]+\)/\([0-9]+\)$" address)
68     (and (not (and (= (match-beginning 0) 0)
69                    (= (match-end 0) (length address))))
70          (error "malformed multicast address: %s" address))
71     (and (not (setq dest (match-string 1 address)))
72          (error "invalid destination specification."))
73     (and (= 0 (setq port (string-to-int (match-string 2 address))))
74          (error "invalid port specification."))
75     (and (= 0 (setq ttl (string-to-int (match-string 3 address))))
76          (error "invalid ttl specification."))
77     (open-multicast-group-internal name buffer dest port ttl)
78     ))
79
80 ;;; multicast.el ends here