unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
@ 2019-02-22 13:43 Lars Ingebrigtsen
  2019-02-22 13:51 ` Lars Ingebrigtsen
  2019-02-22 14:00 ` Robert Pluim
  0 siblings, 2 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-02-22 13:43 UTC (permalink / raw
  To: 34617


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






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
  2019-02-22 13:43 bug#34617: 27.0.50; Can't bind a server process to all interfaces? Lars Ingebrigtsen
@ 2019-02-22 13:51 ` Lars Ingebrigtsen
  2019-02-22 14:05   ` Lars Ingebrigtsen
  2019-02-22 14:00 ` Robert Pluim
  1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-02-22 13:51 UTC (permalink / raw
  To: 34617

Somebody on irc told me that

  :host "0.0.0.0"

will give me the INADDR_ANY thing I want...  So perhaps that should just
be added to the doc string?

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






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
  2019-02-22 13:43 bug#34617: 27.0.50; Can't bind a server process to all interfaces? Lars Ingebrigtsen
  2019-02-22 13:51 ` Lars Ingebrigtsen
@ 2019-02-22 14:00 ` Robert Pluim
  1 sibling, 0 replies; 8+ messages in thread
From: Robert Pluim @ 2019-02-22 14:00 UTC (permalink / raw
  To: Lars Ingebrigtsen; +Cc: 34617

Lars Ingebrigtsen <larsi@gnus.org> writes:

> 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?
>

Does :host "0.0.0.0" not work? Seems ok to me:

(setq proc (make-network-process
                 :name "foo"
                 :family 'ipv4
                 :service 6666
                 :host "0.0.0.0"
                 :server t))
                         
M-x list-processes

foo             --      listen  --                        --           Main         (network server on 0.0.0.0)
foo <127.0.0... --      open    foo <127.0.0.1:63650>     --           Main         (network connection to 127.0.0.1)
foo <172.26.... --      open    foo <172.26.128.66:63605> --           Main         (network connection to 172.26.128.66)
foo <172.26.... --      open    foo <172.26.148.3:63628>  --           Main         (network connection to 172.26.148.3)



Robert





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
  2019-02-22 13:51 ` Lars Ingebrigtsen
@ 2019-02-22 14:05   ` Lars Ingebrigtsen
  2019-02-22 14:25     ` Robert Pluim
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-02-22 14:05 UTC (permalink / raw
  To: 34617

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Somebody on irc told me that
>
>   :host "0.0.0.0"
>
> will give me the INADDR_ANY thing I want...  So perhaps that should just
> be added to the doc string?

And the same somebody pointed out that then you can't listen to ipv6 and
ipv4 at the same time.  Probably?

So perhaps there should be a

  :host 'any

thing to just listen to a port on all available interfaces...

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





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
  2019-02-22 14:05   ` Lars Ingebrigtsen
@ 2019-02-22 14:25     ` Robert Pluim
  2019-02-22 14:28       ` Lars Ingebrigtsen
  2019-09-21  8:00       ` Lars Ingebrigtsen
  0 siblings, 2 replies; 8+ messages in thread
From: Robert Pluim @ 2019-02-22 14:25 UTC (permalink / raw
  To: Lars Ingebrigtsen; +Cc: 34617

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> Somebody on irc told me that
>>
>>   :host "0.0.0.0"
>>
>> will give me the INADDR_ANY thing I want...  So perhaps that should just
>> be added to the doc string?
>
> And the same somebody pointed out that then you can't listen to ipv6 and
> ipv4 at the same time.  Probably?
>

You can, by listening to "::" but it depends on the underlying stack
whether it works or not. It works for me :-)

> So perhaps there should be a
>
>   :host 'any
>
> thing to just listen to a port on all available interfaces...

Sure, as long as we make it error out if :family is specified, unless
you want

:family 'ipv6
:host 'any

to mean 'listen only on IPv6' interfaces and similarly for 'ipv4.

Robert





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
  2019-02-22 14:25     ` Robert Pluim
@ 2019-02-22 14:28       ` Lars Ingebrigtsen
  2019-02-22 15:39         ` Robert Pluim
  2019-09-21  8:00       ` Lars Ingebrigtsen
  1 sibling, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-02-22 14:28 UTC (permalink / raw
  To: 34617

Robert Pluim <rpluim@gmail.com> writes:

> You can, by listening to "::" but it depends on the underlying stack
> whether it works or not. It works for me :-)

That's a syntax I was definitely not aware of.  :-)  Is that new?

>> So perhaps there should be a
>>
>>   :host 'any
>>
>> thing to just listen to a port on all available interfaces...
>
> Sure, as long as we make it error out if :family is specified, unless
> you want
>
> :family 'ipv6
> :host 'any
>
> to mean 'listen only on IPv6' interfaces and similarly for 'ipv4.

Yeah, I think that would be logical?

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





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
  2019-02-22 14:28       ` Lars Ingebrigtsen
@ 2019-02-22 15:39         ` Robert Pluim
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Pluim @ 2019-02-22 15:39 UTC (permalink / raw
  To: Lars Ingebrigtsen; +Cc: 34617

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Robert Pluim <rpluim@gmail.com> writes:
>
>> You can, by listening to "::" but it depends on the underlying stack
>> whether it works or not. It works for me :-)
>
> That's a syntax I was definitely not aware of.  :-)  Is that new?
>

Itʼs the IPv6 equivalent of INADDR_ANY, itʼs been around basically
forever.

>>> So perhaps there should be a
>>>
>>>   :host 'any
>>>
>>> thing to just listen to a port on all available interfaces...
>>
>> Sure, as long as we make it error out if :family is specified, unless
>> you want
>>
>> :family 'ipv6
>> :host 'any
>>
>> to mean 'listen only on IPv6' interfaces and similarly for 'ipv4.
>
> Yeah, I think that would be logical?

I guess so, although

:family 'ipv6
:host "::"

currently results in listening on v4 as well for me here, so some work
would be required to implement it.

(why this sudden desire to listen to everything in Emacs? Are you
re-implementing gmane in elisp? ;-) )

Robert





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#34617: 27.0.50; Can't bind a server process to all interfaces?
  2019-02-22 14:25     ` Robert Pluim
  2019-02-22 14:28       ` Lars Ingebrigtsen
@ 2019-09-21  8:00       ` Lars Ingebrigtsen
  1 sibling, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-21  8:00 UTC (permalink / raw
  To: 34617

Robert Pluim <rpluim@gmail.com> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> Lars Ingebrigtsen <larsi@gnus.org> writes:
>>
>>> Somebody on irc told me that
>>>
>>>   :host "0.0.0.0"
>>>
>>> will give me the INADDR_ANY thing I want...  So perhaps that should just
>>> be added to the doc string?
>>
>> And the same somebody pointed out that then you can't listen to ipv6 and
>> ipv4 at the same time.  Probably?
>
> You can, by listening to "::" but it depends on the underlying stack
> whether it works or not. It works for me :-)

I've now just mentioned this in the doc string.

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





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-21  8:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-22 13:43 bug#34617: 27.0.50; Can't bind a server process to all interfaces? Lars Ingebrigtsen
2019-02-22 13:51 ` Lars Ingebrigtsen
2019-02-22 14:05   ` Lars Ingebrigtsen
2019-02-22 14:25     ` Robert Pluim
2019-02-22 14:28       ` Lars Ingebrigtsen
2019-02-22 15:39         ` Robert Pluim
2019-09-21  8:00       ` Lars Ingebrigtsen
2019-02-22 14:00 ` Robert Pluim

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).