[erlang-questions] strange behaviour of gen_tcp:connect

Gamoto <>
Tue Apr 7 18:52:38 CEST 2009


I mean there is neither server listening on this port nor other applications using it.
I repeat what I observed: "connect"-erlang is suspended on windows server 2003, "connect"- php is not suspended on windows server 2003.
>On Tue, Apr 07, 2009 at 11:13:46AM +0200, Gamoto wrote:
>> I an windows server 2003. I don't understand why gen_tcp:connect returns ALWAYS an error.
>> "connect" should be blocking, the port is free, I didn't precise a timeout.  I also tried with "localhost".
>> Another strange effect: error returned is "econnrefused" or, when another emacs is opened with erlang code inside, the returned error is "timeout" !!!
>> Is it "normal" with Erlang ?
>
>What do you mean by "the port is free". Something must
>be listening on port 1688 for the loopback interface.
>If nothing is listening on the port, the TCP stack
>of the OS will immediately inform gen_tcp about 
>that, hence the econnrefused.
>
>This is basic TCP/IP, no Erlang quirks.
>
>I also have a Win2003Server:
>
>1> gen_tcp:connect("127.0.0.1",3389,[binary, {packet, 0}]).
>{ok,#Port<0.444>}
>
>since I have a Windows remote desktop server
>listening on port 3389.
>
>If you really want the IP address, use the Erlang
>gen_tcp IP address tuple as documented in:
>	http://www.erlang.org/doc/man/inet.html
>{127,0,0,1} instead of "127.0.0.1". The first
>is taken as an IP address direct, the second
>is processed through the name resolver.
>
>> 
>> John
>> 
>> start()->
>>     case gen_tcp:connect("127.0.0.1",1688,[binary, {packet, 0}]) of
>>         {ok,Socket}->	
>> 	    io:format("Socket established~n"),
>> 	    loop(Socket);
>> 	{error,Reason}->
>> 	    io:format("Error on connect: ~s~n",[Reason])
>>     end.
>> 
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>-- 
>
>/ Raimo Niskanen, Erlang/OTP, Ericsson AB




More information about the erlang-questions mailing list