From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: Allow specifying services as symbols? Date: Tue, 19 Oct 2010 16:25:08 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87wrpdnadn.fsf@lifelogs.com> References: <87sk02ngog.fsf@lifelogs.com> <87pqv69buj.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1287523529 14369 80.91.229.12 (19 Oct 2010 21:25:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 19 Oct 2010 21:25:29 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 19 23:25:28 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P8JgV-0002hX-Tj for ged-emacs-devel@m.gmane.org; Tue, 19 Oct 2010 23:25:28 +0200 Original-Received: from localhost ([127.0.0.1]:52421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8JgV-0007vC-Cc for ged-emacs-devel@m.gmane.org; Tue, 19 Oct 2010 17:25:27 -0400 Original-Received: from [140.186.70.92] (port=56643 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P8JgQ-0007v3-7y for emacs-devel@gnu.org; Tue, 19 Oct 2010 17:25:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P8JgO-0004Y3-Un for emacs-devel@gnu.org; Tue, 19 Oct 2010 17:25:22 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:34965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P8JgO-0004Xu-JM for emacs-devel@gnu.org; Tue, 19 Oct 2010 17:25:20 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1P8JgM-0002eT-PN for emacs-devel@gnu.org; Tue, 19 Oct 2010 23:25:18 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Oct 2010 23:25:18 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 19 Oct 2010 23:25:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 105 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:RhqwrmseFhSlqhT88PJoGwVk6VI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:131862 Archived-At: --=-=-= Content-Type: text/plain On Tue, 19 Oct 2010 16:17:08 -0400 Chong Yidong wrote: CY> Ted Zlatanov writes: >> My patch, attached here, corrects the docstring and fixes the two places >> where the port should be a symbol (you only got one, I think, because of >> the "goto open_socket" right before "#endif /* HAVE_GETADDRINFO */"). >> >> I'll write a manual patch as well if this is acceptable. CY> Seems OK to me. The patch to the manual and the code is below. I can't commit it until much later, so if anyone wants to do it sooner, feel free. Ted --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=make-network-connection-with-symbol-service.patch === modified file 'doc/lispref/processes.texi' --- doc/lispref/processes.texi 2010-08-25 05:23:47 +0000 +++ doc/lispref/processes.texi 2010-10-19 21:22:42 +0000 @@ -1937,9 +1937,10 @@ @var{buffer-or-name} is @code{nil}, it means that the connection is not associated with any buffer. -The arguments @var{host} and @var{service} specify where to connect to; -@var{host} is the host name (a string), and @var{service} is the name of -a defined network service (a string) or a port number (an integer). +The arguments @var{host} and @var{service} specify where to connect +to; @var{host} is the host name (a string), and @var{service} is the +name of a defined network service (a string or a symbol) or a port +number (an integer). @end defun @node Network Servers @@ -2076,10 +2077,10 @@ @item :service @var{service} @var{service} specifies a port number to connect to, or, for a server, -the port number to listen on. It should be a service name that -translates to a port number, or an integer specifying the port number -directly. For a server, it can also be @code{t}, which means to let -the system select an unused port number. +the port number to listen on. It should be a service name (a string +or a symbol) that translates to a port number, or an integer +specifying the port number directly. For a server, it can also be +@code{t}, which means to let the system select an unused port number. @item :family @var{family} @var{family} specifies the address (and protocol) family for === modified file 'src/process.c' --- src/process.c 2010-10-08 10:14:47 +0000 +++ src/process.c 2010-10-19 18:26:51 +0000 @@ -2978,10 +2978,11 @@ host, and only clients connecting to that address will be accepted. :service SERVICE -- SERVICE is name of the service desired, or an -integer specifying a port number to connect to. If SERVICE is t, -a random port number is selected for the server. (If Emacs was -compiled with getaddrinfo, a port number can also be specified as a -string, e.g. "80", as well as an integer. This is not portable.) +integer specifying a port number to connect to. If SERVICE is t, a +random port number is selected for the server. A port number can also +be specified as a string, e.g. "80", or a symbol whose name will be +used, as well as an integer. This is not necessarily portable; either +getaddrinfo or getservbyname will be used to look up the port number. :type TYPE -- TYPE is the type of connection. The default (nil) is a stream type connection, `datagram' creates a datagram type connection, @@ -3303,6 +3304,11 @@ Otherwise, use getservbyname to lookup the service. */ if (!NILP (host)) { + /* Take a symbol as the service and convert it to a string. */ + if (SYMBOLP (service)) + { + service = Fsymbol_name (service); + } /* SERVICE can either be a string or int. Convert to a C string for later use by getaddrinfo. */ @@ -3347,6 +3353,12 @@ /* We end up here if getaddrinfo is not defined, or in case no hostname has been specified (e.g. for a local server process). */ + /* Take a symbol as the service and convert it to a string. */ + if (SYMBOLP (service)) + { + service = Fsymbol_name (service); + } + if (EQ (service, Qt)) port = 0; else if (INTEGERP (service)) --=-=-=--