erlang

Erlang build failure: error writing file

喜你入骨 提交于 2019-12-11 01:58:26
问题 I am new to Erlang and am trying to build the Erlang package. I am using R13B version. Its an old version but am using it because it already used in a pre-existing project. I am getting the following err: ...rlang/build/lib/hipe/rtl/../ebin/hipe_rtl.bea#: error writing file I searched the internet and potential reason was lack of permission. The directory it is writing to my home directory. Can someone please help me out here? 来源: https://stackoverflow.com/questions/32387597/erlang-build

Debugging ErlyDB and MySQL

烂漫一生 提交于 2019-12-11 01:54:07
问题 I am experimenting with ErlyDB in a non-erlyweb environment and I am not having much luck. I have a 'Thing' table for testing, and a corresponding Thing module: -module(thing). -export([table/0, fields/0]). table() -> thing. fields() -> [name, value]. The module itself works - I can query the database fine using ( [Thing] = thing:find({name, '=', "test"}) ). When I try and save a new record, however things aren't so good. I consistently see the following error: mysql_conn:426: fetch <<"BEGIN"

Simple Distributed Erlang

大城市里の小女人 提交于 2019-12-11 00:40:19
问题 I've got a simple module: -module(dist). -compile([add/3]). add(From,X,Y) -> From ! X+Y. And I'm starting two nodes. One with erl -sname foo and another with erl -sname bar On the bar node I'm doing: > c(dist). {ok,dist} > self(). <0.37.0> > spawn('foo@unknown-00-23-6c-83-af-bd', dist, add, [self(), 3, 5]). But the reponse I get is: Error in process <0.48.0> on node 'foo@unknown-00-23-6c-83-af-bd' with exit value: {undef,[{dist,add,[<8965.37.0>,3,5]}]} What does this error mean? I wondered if

Ejabberd custom IQ Handler: getting feature-not-implemented or service-unavailable

浪尽此生 提交于 2019-12-10 23:52:44
问题 I stripped mod_last.erl to test the creation of a IQHandler (pasted only the part that matters): start(Host, Opts) -> IQDisc = gen_mod:get_opt(iqdisc, Opts, fun gen_iq_handler:check_type/1, one_queue), gen_iq_handler:add_iq_handler(ejabberd_local, Host, <<"join">>, ?MODULE, process_local_iq, IQDisc). stop(Host) -> gen_iq_handler:remove_iq_handler(ejabberd_local, Host, <<"join">>). process_local_iq(_From, _To, #iq{type = Type, sub_el = SubEl} = IQ) -> case Type of set -> IQ#iq{type = error,

Simple chat system over websockets with reconnection feature

偶尔善良 提交于 2019-12-10 23:44:25
问题 I have seen many examples of chat room systems over websocket implemented with erlang and cowboy. Most of the examples I have seen use gproc. In practice each websocket handler registers itself with gproc and then broadcasts/receives messages from it. Since a user could close by accident the webpage I am thinking about connecting to the websocket handler a gen_fsm which actually broadcasts/receives all the messages from gproc. In this way the gen_fsm could switch from a "connected" state to a

asdf-erlang doesn't install man pages

谁说胖子不能爱 提交于 2019-12-10 22:55:21
问题 I am using asdf + asdf-erlang as my version manager for Erlang. All seems to be working fine, except that typing erl -man mnesia results in No manual entry for mnesia . I have installed all dependencies mentioned on the asdf-erlang github page. I have also installed xsltproc and fop. Unfortunately "man" folder located under ~/.asdf/installs/erlang/18.3/lib/erlang/erts-73/ is empty. I haven't found man pages being generated elsewhere. I was trying to locate build log, but I was not successful

If you send a message to a process before giving out its pid, is it guaranteed to recieve that message first?

做~自己de王妃 提交于 2019-12-10 21:17:54
问题 Say there is a process B , which receives a pid and sends m2 to it. If you spawn A and send it m1 , and then send A to B , is A guaranteed to get m1 before m2 ? In other words, can this crash? -module(test). -compile(export_all). test() -> B = spawn_link(fun() -> receive P -> P ! m2 end end), A = spawn_link(fun() -> receive X -> X=m1 end end), A ! m1, B ! A. 回答1: Your code cannot crash because all processes are local . B = spawn_link(fun() -> receive P -> P ! m2 end end), % 1 A = spawn_link

Variable in Erlang

﹥>﹥吖頭↗ 提交于 2019-12-10 20:50:37
问题 I have a very simple Erlang program: -module(test). -export([start/0]). Code = "Z00887". start() -> io:fwrite(Code). And I have follows two errors: c:/erl6.1/dev/test.erl:4: syntax error before: Code c:/erl6.1/dev/test.erl:5: variable 'Code' is unbound Could you please help me correctly using variables in my code. 回答1: You are defining a variable that is global to the module, which is not allowed. Remember, "variables" in Erlang are really "symbols", so there is no concept of a "global"

Erlang: How does one avoid Lists being translated to ASCII Strings?

↘锁芯ラ 提交于 2019-12-10 19:36:47
问题 [97, 98, 99]. yields "abc", in the Erlang shell. I realize this is because the ASCII values of a, b and c are 97, 98 and 99 respectively. So.. how would one go about returning [97,98,99] without Erlang translating it to ASCII? 回答1: You can try io:format("~w~n", [ListHere]) , which should simply avoid interpreting the data. 回答2: Try this YourList ++ [0] With "abc" "abc" ++ [0] [97,98,99,0] 来源: https://stackoverflow.com/questions/3833078/erlang-how-does-one-avoid-lists-being-translated-to-ascii

How to send message to receive in YAWS/Erlang

淺唱寂寞╮ 提交于 2019-12-10 19:22:38
问题 Normally in Erlang programmers use ! symbol to send message to receive in concurrent programming but how do we do it in yaws? Say I am trying to do this> <erl> out(Arg) -> loop("bad"). loop(X)-> receive good -> {html, "Good"}; bad -> {html, "bad"} end. </erl> This program keeps waiting for a message, How do I send message to it? 回答1: If you want to have one process send a message to another, it's clear you need two processes. When Yaws receives a HTTP request, by default it dispatches the