0

在 ejabberd 模块中,我使用此方法:

httpc:request(post, {Url, Header

它似乎不是异步的,erlang有没有办法在一个单独的线程上启动它???

4

2 回答 2

0
Sample method-
// module name - sample
http_request(Method,Url,Body)->
httpc:request(Method, {Url, [], "application/x-www-form-urlencoded", Body}, [], []).

你会这样打电话——

 spawn(sample, http_request, [post,”www.sample.com”,”some sample data”]). 
 %% syntax spawn(Module, Name, Args) -> pid()

http://erlang.org/doc/getting_started/conc_prog.html http://erlang.org/doc/reference_manual/processes.html

于 2017-04-24T05:12:56.287 回答
0

我用过这个:

    spawn(mod_http_offline, http_request, [Url, Post]).

    % Function that make a call
    http_request(Url, Post)->
      TypeData = "application/x-www-form-urlencoded",
      Header = [],
      HTTPOptions = [],
      Options = [],
      httpc:request(post, {Url, Header, TypeData,list_to_binary(Post)}, HTTPOptions, Options).

但是当我编译时,得到这个:

Warning: function http_request/2 is unused

并且没有调用函数

于 2017-04-24T07:33:34.780 回答