diff options
| author | Kim F. Storm | 2003-09-23 22:05:38 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2003-09-23 22:05:38 +0000 |
| commit | 0bbffed703731f8ded124f0c405633d0ad95d16e (patch) | |
| tree | fdc692a93b1bd88702ae265631f983a06ae54737 | |
| parent | ef6ae4ff6d9d0aa909554a654cecbf38334115a4 (diff) | |
| download | emacs-0bbffed703731f8ded124f0c405633d0ad95d16e.tar.gz emacs-0bbffed703731f8ded124f0c405633d0ad95d16e.zip | |
(Network, Network Servers): Fix typos.
(Low-Level Network): Add timeout value for :server keyword.
Add new option keywords to make-network-process.
Add set-network-process-options.
Explain how to test availability of network options.
| -rw-r--r-- | lispref/processes.texi | 157 |
1 files changed, 124 insertions, 33 deletions
diff --git a/lispref/processes.texi b/lispref/processes.texi index ab63d414471..4887b880abb 100644 --- a/lispref/processes.texi +++ b/lispref/processes.texi | |||
| @@ -1473,10 +1473,11 @@ Transaction queues are implemented by means of a filter function. | |||
| 1473 | @section Network Connections | 1473 | @section Network Connections |
| 1474 | @cindex network connection | 1474 | @cindex network connection |
| 1475 | @cindex TCP | 1475 | @cindex TCP |
| 1476 | @cindex UDP | ||
| 1476 | 1477 | ||
| 1477 | Emacs Lisp programs can open TCP and datagram network connections to | 1478 | Emacs Lisp programs can open stream (TCP) and datagram (UDP) network |
| 1478 | other processes on the same machine or other machines. A network | 1479 | connections to other processes on the same machine or other machines. |
| 1479 | connection is handled by Lisp much like a subprocess, and is | 1480 | A network connection is handled by Lisp much like a subprocess, and is |
| 1480 | represented by a process object. However, the process you are | 1481 | represented by a process object. However, the process you are |
| 1481 | communicating with is not a child of the Emacs process, so it has no | 1482 | communicating with is not a child of the Emacs process, so it has no |
| 1482 | process @sc{id}, and you can't kill it or send it signals. All you | 1483 | process @sc{id}, and you can't kill it or send it signals. All you |
| @@ -1504,12 +1505,13 @@ subprocess. @xref{Process Information}. | |||
| 1504 | You can stop and resume operation of a network processes by calling | 1505 | You can stop and resume operation of a network processes by calling |
| 1505 | @code{stop-process} and @code{continue-process}. For a server | 1506 | @code{stop-process} and @code{continue-process}. For a server |
| 1506 | process, being stopped means not accepting new connections. (Up to 5 | 1507 | process, being stopped means not accepting new connections. (Up to 5 |
| 1507 | connection requests will be queued for when you resume the server; | 1508 | connection requests will be queued for when you resume the server; you |
| 1508 | this limit is imposed by the operating system.) For a network | 1509 | can increase this limit, unless it is imposed by the operating |
| 1509 | connection, being stopped means not processing input (any arriving | 1510 | systems.) For a network connection, being stopped means not |
| 1510 | input waits until you resume the connection). You can use the | 1511 | processing input (any arriving input waits until you resume the |
| 1511 | function @code{process-command} to determine whether a network | 1512 | connection). You can use the function @code{process-command} to |
| 1512 | connection or server is stopped; a non-@code{nil} value means yes. | 1513 | determine whether a network connection or server is stopped; a |
| 1514 | non-@code{nil} value means yes. | ||
| 1513 | 1515 | ||
| 1514 | @defun open-network-stream name buffer-or-name host service | 1516 | @defun open-network-stream name buffer-or-name host service |
| 1515 | This function opens a TCP connection, and returns a process object | 1517 | This function opens a TCP connection, and returns a process object |
| @@ -1565,7 +1567,7 @@ The associated value is the process buffer. | |||
| 1565 | @item :filter | 1567 | @item :filter |
| 1566 | The associated value is the process filter function. | 1568 | The associated value is the process filter function. |
| 1567 | @item :sentinel | 1569 | @item :sentinel |
| 1568 | The associated value is the process filter function. | 1570 | The associated value is the process sentinel function. |
| 1569 | @item :remote | 1571 | @item :remote |
| 1570 | In a connection, this is the address in internal format of the remote peer. | 1572 | In a connection, this is the address in internal format of the remote peer. |
| 1571 | @item :local | 1573 | @item :local |
| @@ -1599,12 +1601,12 @@ The connection's process name is constructed by concatenating the | |||
| 1599 | server process' @var{name} with a client identification string. The | 1601 | server process' @var{name} with a client identification string. The |
| 1600 | client identification string for an IPv4 connection looks like | 1602 | client identification string for an IPv4 connection looks like |
| 1601 | @samp{<@var{a}.@var{b}.@var{c}.@var{d}:@var{p}>}. Otherwise, it is a | 1603 | @samp{<@var{a}.@var{b}.@var{c}.@var{d}:@var{p}>}. Otherwise, it is a |
| 1602 | unique number in brackets, as in @samp{<@var{nnn>}}. The number | 1604 | unique number in brackets, as in @samp{<@var{nnn}>}. The number |
| 1603 | is unique for each connection in the Emacs session. | 1605 | is unique for each connection in the Emacs session. |
| 1604 | 1606 | ||
| 1605 | @item | 1607 | @item |
| 1606 | If the server's filter is non-@code{nil}, the connection process does | 1608 | If the server's filter is non-@code{nil}, the connection process does |
| 1607 | not get a separate process buffer; otherwise, Emacs creates a bew | 1609 | not get a separate process buffer; otherwise, Emacs creates a new |
| 1608 | buffer for the purpose. The buffer name is the server's buffer name | 1610 | buffer for the purpose. The buffer name is the server's buffer name |
| 1609 | or process name, concatenated with the client identification string. | 1611 | or process name, concatenated with the client identification string. |
| 1610 | 1612 | ||
| @@ -1691,8 +1693,8 @@ This function creates a network connection or server and returns the | |||
| 1691 | process object that represents it. The arguments @var{args} are a | 1693 | process object that represents it. The arguments @var{args} are a |
| 1692 | list of keyword/argument pairs. Omitting a keyword is always | 1694 | list of keyword/argument pairs. Omitting a keyword is always |
| 1693 | equivalent to specifying it with value @code{nil}, except for | 1695 | equivalent to specifying it with value @code{nil}, except for |
| 1694 | @code{:coding} and @code{:filter-multibyte}. Here are the meaningful | 1696 | @code{:coding}, @code{:filter-multibyte}, and @code{:reuseaddr}. Here |
| 1695 | keywords: | 1697 | are the meaningful keywords: |
| 1696 | 1698 | ||
| 1697 | @table @asis | 1699 | @table @asis |
| 1698 | @item :name name | 1700 | @item :name name |
| @@ -1706,7 +1708,9 @@ connection. Both connections and servers can be of either type. | |||
| 1706 | 1708 | ||
| 1707 | @item :server @var{server-flag} | 1709 | @item :server @var{server-flag} |
| 1708 | If @var{server-flag} is non-@code{nil}, create a server. Otherwise, | 1710 | If @var{server-flag} is non-@code{nil}, create a server. Otherwise, |
| 1709 | create a connection. | 1711 | create a connection. For a stream type server, @var{server-flag} may |
| 1712 | be an integer which then specifies the length of the queue of pending | ||
| 1713 | connections to the server. The default queue length is 5. | ||
| 1710 | 1714 | ||
| 1711 | @item :host @var{host} | 1715 | @item :host @var{host} |
| 1712 | Specify the host to connect to. @var{host} should be a host name or | 1716 | Specify the host to connect to. @var{host} should be a host name or |
| @@ -1785,14 +1789,10 @@ encoding data sent to it, specify @code{(@var{decoding} . | |||
| 1785 | @var{encoding})} for @var{coding}. | 1789 | @var{encoding})} for @var{coding}. |
| 1786 | 1790 | ||
| 1787 | If you don't specify this keyword at all, the default | 1791 | If you don't specify this keyword at all, the default |
| 1788 | is to determine the coding systemx from the data. | 1792 | is to determine the coding systems from the data. |
| 1789 | |||
| 1790 | @item :options @var{options} | ||
| 1791 | Set the specified options for the network process. See | ||
| 1792 | @code{set-network-process-options} for details. | ||
| 1793 | 1793 | ||
| 1794 | @item :noquery @var{query-flag} | 1794 | @item :noquery @var{query-flag} |
| 1795 | Initialize the process query flag to @var{query-flag}. | 1795 | Initialize the process query flag to @var{query-flag}. @xref{Query Before Exit}. |
| 1796 | 1796 | ||
| 1797 | @item :filter @var{filter} | 1797 | @item :filter @var{filter} |
| 1798 | Initialize the process filter to @var{filter}. | 1798 | Initialize the process filter to @var{filter}. |
| @@ -1819,10 +1819,84 @@ happened. | |||
| 1819 | Initialize the process plist to @var{plist}. | 1819 | Initialize the process plist to @var{plist}. |
| 1820 | @end table | 1820 | @end table |
| 1821 | 1821 | ||
| 1822 | The following network options can be specified for the network | ||
| 1823 | process. Except for @code{:reuseaddr}, you can set or modify these | ||
| 1824 | options later using @code{set-network-process-option}. | ||
| 1825 | |||
| 1826 | For a server process, the options specified with | ||
| 1827 | @code{make-network-process} are not inherited by the client | ||
| 1828 | connections, so you will need to set the necessary options for each | ||
| 1829 | child connection as they are created. | ||
| 1830 | |||
| 1831 | @table asis | ||
| 1832 | @item :bindtodevice @var{device-name} | ||
| 1833 | If @var{device-name} is a non-empty string identifying a network | ||
| 1834 | interface name (see @code{network-interface-list}), only handle | ||
| 1835 | packets received on that interface. If @var{device-name} is nil (the | ||
| 1836 | default), handle packets received on any interface. | ||
| 1837 | |||
| 1838 | Using this option may require special privileges on some systems. | ||
| 1839 | |||
| 1840 | @item :broadcast @var{broadcast-flag} | ||
| 1841 | If @var{broadcast-flag} is non-@code{nil} for a datagram process, the | ||
| 1842 | process will receive datagram packet sent to a broadcast address, and | ||
| 1843 | be able to send packets to a broadcast address. Ignored for a stream | ||
| 1844 | connection. | ||
| 1845 | |||
| 1846 | @item :dontroute @var{dontroute-flag} | ||
| 1847 | If @var{dontroute-flag} is non-@code{nil}, the process can only send | ||
| 1848 | to hosts on the same network as the local host. | ||
| 1849 | |||
| 1850 | @item :keepalive @var{keepalive-flag} | ||
| 1851 | If @var{keepalive-flag} is non-@code{nil} for a stream connection, | ||
| 1852 | enable exchange of low-level keep-alive messa | ||
| 1853 | |||
| 1854 | @item :linger @var{linger-arg} | ||
| 1855 | If @var{linger-arg} is non-@code{nil}, wait for successful | ||
| 1856 | transmission of all queued packets on the connection before it is | ||
| 1857 | deleted (see @code{delete-process}). If @var{linger-arg} is an | ||
| 1858 | integer, it specifies the maximum time in seconds to wait for queued | ||
| 1859 | packets to be sent before closing the connection. Default is | ||
| 1860 | @code{nil} which means to discard unsent queued packets when the | ||
| 1861 | process is deleted. | ||
| 1862 | |||
| 1863 | @item :oobinline @var{oobinline-flag} | ||
| 1864 | If @var{oobinline-flag} is non-@code{nil} for a stream connection, | ||
| 1865 | receive out-of-band data in the normal data stream. Otherwise, ignore | ||
| 1866 | out-of-band data. | ||
| 1867 | |||
| 1868 | @item :priority @var{priority} | ||
| 1869 | Set the priority for packets sent on this connection to the integer | ||
| 1870 | @var{priority}. The interpretation of this number is protocol | ||
| 1871 | specific, such as setting the TOS (type of service) field on IP | ||
| 1872 | packets sent on this connection. It may also have system dependent | ||
| 1873 | effects, such as selecting a specific output queue on the network | ||
| 1874 | interface. | ||
| 1875 | |||
| 1876 | @item :reuseaddr @var{reuseaddr-flag} | ||
| 1877 | If @var{reuseaddr-flag} is non-@code{nil} (the default) for a stream | ||
| 1878 | server process, allow this server to reuse a specific port number (see | ||
| 1879 | @code{:service}) unless another process on this host is already | ||
| 1880 | listening on that port. If @var{reuseaddr-flag} is @code{nil}, there | ||
| 1881 | may be a period of time after the last use of that port (by any | ||
| 1882 | process on the host), where it is not possible to make a new server on | ||
| 1883 | that port. | ||
| 1884 | |||
| 1885 | @end table | ||
| 1886 | |||
| 1822 | The original argument list, modified with the actual connection | 1887 | The original argument list, modified with the actual connection |
| 1823 | information, is available via the `process-contact' function. | 1888 | information, is available via the `process-contact' function. |
| 1824 | @end defun | 1889 | @end defun |
| 1825 | 1890 | ||
| 1891 | @defun set-network-process-option process option value | ||
| 1892 | This function sets or modifies a network option for network process | ||
| 1893 | @var{process}. See @code{make-network-process} for details of options | ||
| 1894 | @var{option} and their corresponding values @var{value}. | ||
| 1895 | |||
| 1896 | The current setting of an option is available via the | ||
| 1897 | `process-contact' function. | ||
| 1898 | @end defun | ||
| 1899 | |||
| 1826 | @defun network-interface-list | 1900 | @defun network-interface-list |
| 1827 | This function returns a list describing the network interfaces | 1901 | This function returns a list describing the network interfaces |
| 1828 | of the machine you are using. The value is an alist whose | 1902 | of the machine you are using. The value is an alist whose |
| @@ -1869,9 +1943,12 @@ the port number. | |||
| 1869 | @end example | 1943 | @end example |
| 1870 | 1944 | ||
| 1871 | @noindent | 1945 | @noindent |
| 1872 | The result is @code{t} if it works to specify @var{keyword} with value | 1946 | The result of the first form is @code{t} if it works to specify |
| 1873 | @var{value} in @code{make-network-process}. Here are some of the | 1947 | @var{keyword} with value @var{value} in @code{make-network-process}. |
| 1874 | @var{keyword}---@var{value} pairs you can test in this way. | 1948 | The result of the second form is @code{t} if @var{keyword} is |
| 1949 | supported by @code{make-network-process}. Here are some of the | ||
| 1950 | @var{keyword}---@var{value} pairs you can test in | ||
| 1951 | this way. | ||
| 1875 | 1952 | ||
| 1876 | @table @code | 1953 | @table @code |
| 1877 | @item (:nowait t) | 1954 | @item (:nowait t) |
| @@ -1882,15 +1959,29 @@ Non-@code{nil} if datagrams are supported. | |||
| 1882 | Non-@code{nil} if local (aka ``UNIX domain'') sockets are supported. | 1959 | Non-@code{nil} if local (aka ``UNIX domain'') sockets are supported. |
| 1883 | @item (:service t) | 1960 | @item (:service t) |
| 1884 | Non-@code{nil} if the system can select the port for a server. | 1961 | Non-@code{nil} if the system can select the port for a server. |
| 1885 | @item (:options bindtodevice) | 1962 | @end table |
| 1886 | @itemx (:options broadcast) | 1963 | |
| 1887 | @itemx (:options dontroute) | 1964 | To test for the availability of a given network option, use |
| 1888 | @itemx (:options keepalive) | 1965 | @code{featurep} like this: |
| 1889 | @itemx (:options linger) | 1966 | |
| 1890 | @itemx (:options oobinline) | 1967 | @example |
| 1891 | @itemx (:options priority) | 1968 | (featurep 'make-network-process '@var{keyword}) |
| 1892 | @itemx (:options reuseaddr) | 1969 | @end example |
| 1893 | That particular socket option is supported. | 1970 | |
| 1971 | Here are some of the option @var{keyword}s you can test in | ||
| 1972 | this way. | ||
| 1973 | |||
| 1974 | @table @code | ||
| 1975 | @item :bindtodevice | ||
| 1976 | @itemx :broadcast | ||
| 1977 | @itemx :dontroute | ||
| 1978 | @itemx :keepalive | ||
| 1979 | @itemx :linger | ||
| 1980 | @itemx :oobinline | ||
| 1981 | @itemx :priority | ||
| 1982 | @itemx :reuseaddr | ||
| 1983 | That particular network option is supported by | ||
| 1984 | @code{make-network-process} and @code{set-network-process-option}. | ||
| 1894 | @end table | 1985 | @end table |
| 1895 | 1986 | ||
| 1896 | @ignore | 1987 | @ignore |