[erlang-questions] : Re: strange behaviour of gen_tcp:connect

Raimo Niskanen <>
Wed Apr 8 09:08:51 CEST 2009


On Tue, Apr 07, 2009 at 06:52:38PM +0200, Gamoto wrote:
> I mean there is neither server listening on this port nor other applications using it.

If there is no listener on the destination port the correct
response from any connect() is econnrefused. Go and read
some TCP/IP FAQ or book.

> I repeat what I observed: "connect"-erlang is suspended on windows server 2003, "connect"- php is not suspended on windows server 2003.

If PHP connect does not return econnrefused when asked
to connect to a destination port without listener
ask why at some PHP mailing list, not here, because
that sounds very confusing.

If gen_tcp:connect({127,0,0,1}, 1688, [binary, {packet, 0}])
hangs for quite a while and then returns with a timeout
you most probably have a firewall blocking the connect.

If you get different behaviour from an Erlang shell
started within Emacs than from one started from
the command line (cmd.exe) or from the shorcuts
"werl.exe" or "erl.exe", it is probably because
the Erlang node is started with different parameters.
In particular -sname vs -name is known to create
differing name resolver setups, which may since
you use destination "127.0.0.1" instead of {127,0,0,1}
as I recommended, cause differing name lookup
causing differing behaviour. Use an IP tuple
such as {127,0,0,1} when you debug connect problems
to eliminate name resolver problems.

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list