[erlang-questions] Erlang connect by external ip address

Tony Rogvall <>
Tue Jan 18 11:21:11 CET 2011


On 17 jan 2011, at 19.19, Adrian Roe wrote:

> Again a little while since I’ve been here, but I suspect you need to explicitly listen on all IP addresses adding {ip, “0.0.0.0”} to your options.  That and make certain that you don’t have a firewall / routing issue blocking traffic to your public IP on your port.
> 

No. This is default.

It is not obvious from the documentation. But you can check this by:

24> {ok,L} = gen_tcp:listen(37891, []).     
{ok,#Port<0.817>}
25> inet:i().                          
Port Module   Recv Sent Owner    Local Address Foreign Address State  
817  inet_tcp 0    0    <0.61.0> *:37891       *:*             LISTEN 
Port Module Recv Sent Owner Local Address Foreign Address State 

Local address * means that listens on 'any' address.


Compare with 
28> {ok,L} = gen_tcp:listen(37891, [{ip,{127,0,0,1}}]). 
{ok,#Port<0.819>}
29> inet:i().                                              
Port Module   Recv Sent Owner    Local Address   Foreign Address State  
819  inet_tcp 0    0    <0.67.0> localhost:37891 *:*             LISTEN 
Port Module Recv Sent Owner Local Address Foreign Address State 

Here is the address bound to localhost (12.0.0.1).


/Tony



> Adrian
> 
> From:  [mailto:] On Behalf Of Robert Raschke
> Sent: 17 January 2011 17:57
> To: shk
> Cc: 
> Subject: Re: [erlang-questions] Erlang connect by external ip address
> 
> 
> On Mon, Jan 17, 2011 at 5:37 PM, shk <<mailto:>> wrote:
> 
>> 
>> I write simple server application in erlang.
>> 
>> Code of this application: https://gist.github.com/783117
>> 
>> I try to connect to it with telnet. When I connect to localhost or local ip
>> addres which get from route it's ok, but when i try to connect to server
>> with external ip it's don't work.
>> 
>> What's wrong? <<mailto:>>
>> 
>> 
> Not 100% sure, but I think inet or inet6 should be part of your
> gen_tcp:listen/2 option list.
> 
> Robby
> 
> ________________________________
> 
> No virus found in this message.
> Checked by AVG - www.avg.com<http://www.avg.com>
> Version: 10.0.1191 / Virus Database: 1435/3386 - Release Date: 01/17/11

"Have run Make so many times I dunno what's installed anymore"



More information about the erlang-questions mailing list