[erlang-questions] http:request() - can only do one async query ?

Vincent de Phily vincent.dephily@REDACTED
Tue Jul 8 20:21:30 CEST 2008


Hi list,

I want to do asynchronous http requests using the inets module (that's the 
best tool for the job, is it ?), but only the first one seems to work :

$ erl
Erlang (BEAM) emulator version 5.6.3 [source] [64-bit] [smp:2] 
[async-threads:0]

Eshell V5.6.3  (abort with ^G)
1> inets:start().
ok
2> {ok, Ref} = http:request(get, {"http://foobar", []}, [], [{sync, false}]).
{ok,#Ref<0.0.0.72>}
3> receive Rcv -> Rcv after 5000 -> timeout end.
{http,{#Ref<0.0.0.72>,
       {{"HTTP/1.1",200,"OK"},
        [{"connection","Keep-Alive"},
         {"date","Tue, 08 Jul 2008 18:09:21 GMT"},
         {"server","Apache"},
         {"content-length","1053"},
         {"content-type","text/html; charset=UTF-8"},
         {"keep-alive","timeout=15, max=100"}],
        <<"<!DOCTYPE HTML PUBLIC "...>>}}}
4> f(Ref),{ok, Ref} = http:request(get, {"http://foobar", []}, [], [{sync, 
false}]).
{ok,#Ref<0.0.0.89>}
5> receive Rcv -> Rcv after 5000 -> timeout end.
timeout
6>


Works fine with synchronous requests, but I really dont want to use that. What 
am I missing ?
-- 
Vincent de Phily



More information about the erlang-questions mailing list