[erlang-questions] Dialyzer: send_timeout infinity

Henning Diedrich hd2010@REDACTED
Sun Jan 6 09:25:41 CET 2013


I had trouble with Dialyzer from a socket connect option that included {send_timeout, infinity}. Dialyzer felt that made this and all calling functions fail. 

Using an integer like in {send_timeout, 1000000} works.

I saw an old bug report regarding an internal type check for number on that parameter. Maybe that is still in place?

Or is this a feature?

This did not work:

-spec connect(inet:ip_address() | inet:hostname(),inet:port_number()) -> {ok, inet:socket()} | no_return().
connect(Host, Port) ->

	Opts = [ binary, 
			 {packet, 4}, 
			 {delay_send, true}, 
			 {nodelay, false}, 
			 {send_timeout, infinity} ], % Dialyzer does not accept infinity
    
    {ok, Socket} = 
        try
            case gen_tcp:connect(Host, Port, Opts) of

...

This works:

-spec connect(inet:ip_address() | inet:hostname(),inet:port_number()) -> {ok, inet:socket()} | no_return().
connect(Host, Port) ->

	Opts = [ binary, 
			 {packet, 4}, 
			 {delay_send, true}, 
			 {nodelay, false}, 
			 {send_timeout, 10000000000} ], % Dialyzer does not accept infinity
    
    {ok, Socket} = 
        try
            case gen_tcp:connect(Host, Port, Opts) of

….

The actual error messages from Dialyzer were:

erlvolt_conn.erl:93: Function tx_loop/1 will never be called
erlvolt_conn.erl:181: Function consume/1 will never be called
erlvolt_conn.erl:196: Function dispatch/1 will never be called
erlvolt_conn.erl:378: Function encode_pid/1 will never be called
erlvolt_conn.erl:384: Function decode_pid/1 will never be called
erlvolt_wire.erl:1780: Function createConnection/0 has no local return
erlvolt_wire.erl:1791: Function createConnection/1 has no local return
erlvolt_wire.erl:1800: Function createConnection/3 has no local return
erlvolt_wire.erl:1809: Function createConnection/4 has no local return
erlvolt_wire.erl:1820: Function open/4 has no local return
erlvolt_wire.erl:1830: Function connect/2 has no local return

They disappeared by replacing infinity with an integer.

Best,
Henning


More information about the erlang-questions mailing list