Subject: 27.0.50; Can't bind a server process to all interfaces?

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 22 Feb 2019 14:43:48 +0100

I'm looking to bind a server process to all interfaces on the machine.
If I say:

		(make-network-process
		 :name name
		 :family 'ipv4
		 :service port
		 :host (system-name)
		 :server t))

then the process won't be listening to the localhost address, and if I
say :host nil, it'll only be listening to the localhost address.

Am I missing something, or does Emacs just not have a way to listen to
INADDR_ANY?

The code in make-network-process seems to imply that (and could probably
do with a slight rewrite):

  /* :host HOST -- hostname, ip address, or 'local for localhost.  */
  host = Fplist_get (contact, QChost);
  if (NILP (host))
    {
      /* The "connection" function gets it bind info from the address we're
	 given, so use this dummy address if nothing is specified. */
#ifdef HAVE_LOCAL_SOCKETS
      if (family != AF_LOCAL)
#endif
        {
        if (family == AF_INET6)
          host = build_string ("::1");
        else
          host = build_string ("127.0.0.1");
        }
    }
  else
    {
      if (EQ (host, Qlocal))
        {
	/* Depending on setup, "localhost" may map to different IPv4 and/or
	   IPv6 addresses, so it's better to be explicit (Bug#6781).  */
        if (family == AF_INET6)
          host = build_string ("::1");
        else
          host = build_string ("127.0.0.1");
        }
      CHECK_STRING (host);
    }

In GNU Emacs 27.0.50 (build 62, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2019-02-11 built on stories
Repository revision: 2860f6cec56b02120b0b62cb3733c00a9e5359db
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11902000
System Description: Debian GNU/Linux 9 (stretch)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no