erlang

How do you write a fun that's recursive in Erlang?

I'm trying to write a recursive fun in an Erlang shell, but I keep getting an unbound variable exception: 1> Foo = fun(X) -> Foo(X) end. * 1: variable 'Foo' is unbound This probably goes without saying, but I'm not trying to create an infinite loop! This is just a simple example of the error I'm getting. ...

Why does erlang:foo() compile?

Why doesn't the Erlang compiler detect undefined functions in compile time. If I write test.erl: -module(test). -export([start/0]). start() -> erlang:foo(). It compiles fine. Eshell V5.6.5 (abort with ^G) 1> c(test). {ok,test} 2> But crashes runtime. 2> test:start(). ** exception error: undefined function erlang:foo/...

Erlang : RPC to a node with output on that node

Is there a way to make an rpc call to a node, but have the output displayed on that node, not just on the calling node ( in fact I would not be too bothered if the calling node did not display the output ). While I understand that I can use rpc:call( Node, erlang, display, [ someTerm ] ). and that will display "someTerm" on Node, w...

detecting data/node partition errors

The last time I saw a data/partition node error it was because I launched the erlang shell which connected to the node on the same CPU via cookies etc. Immediately after startup the shell dumped the partition error on the screen. This is terribly bothersome.... how do I trap this exception? how do I repair the exception programatically...

How do I turn a list of tuple pairs into a record in Erlang?

Let's say I have this: -record(my_record, {foo, bar, baz}). Keyvalpairs = [{foo, val1}, {bar, val2}, {baz, val3}]. Foorecord = #my_record{foo=val1, bar=val2, baz=val3}. How do I convert Keyvalpairs into Foorecord? ...

Erlang Takeover failing after successful Failover

I have an application distributed over 2 nodes. When I halt() the first node the failover works perfectly, but ( sometimes ? ) when I restart the first node the takeover fails and the application crashes since start_link returns already started. SUPERVISOR REPORT <0.60.0> 2009-05-20 12:12:01 ============...

Prioritizing erlang nodes

Assuming I have a cluster of n erlang nodes, some of which may be on my LAN, while others may be connected using a WAN (i.e. via the internet), what are suitable mechanisms to cater for a) different bandwidth availability/behavior (e.g. latency induced) and b) nodes with differing computational power (or even memory constraints for that ...

howto encrypt erlang rpc calls (and Mnesia replication) and other traffic

I believe that internode communication is taking place in the clear and that the cookie value is strictly used for authentication. (I do not have any proof as yet). How do I encrypt internode comms? How do I encrypt Mnesia replication messages? How do I configure my firewall and packet filters to permit these messages to pass thru? Ho...

Examples of production Erlang deployments

Hello everyone! I am currently learning Erlang Can SO users give interesting examples of any of their Erlang application deployments? I want to gain some insight into common Erlang uses past telecomms, and any problems or unexpected benefits Erlang brought during development/deployment. I hope this will give some broader context and ...

What is the recommended way of encoding/decoding XDR types in erlang?

In another SO discussion, we were talking about interfacing an erlang application to another non-erlang app that is using XDR encoded packets for network communications. Unfortunately, I couldn't really find any real pointers on dealing with XDR data using erlang. So what is the recommended way of dealing with XDR encoded data in erla...

Web server for running PHP+Erlang

I wish to run PHP and Erlang on a web server. Apache is ruled out, because the backend Erlang process would need to handle around 3000 requests concurrently. So definitely something with a smaller memory footprint like lighttpd... Which one would you recommend? And why? ...

Why can't I start a named Erlang node in Windows?

I'm trying to start a named Erlang node using the -sname option in Windows XP Home, but when I run erl, it prints out a long error message, which I don't understand, and quits: >erl -sname allyourcode {error_logger,{{2009,5,25},{16,20,57}},"Protocol: ~p: register error: ~p~n",["in et_tcp",{{badmatch,{error,econnrefused}},[{inet_tcp_dist...

Has anybody used YAWS server as an HTTP Proxy ?

I am planning to setup an YAWS webserver as a HTTP proxy server . I am basically trying to achieve a high throughput HTTP proxy server which should be able to take webscale load. The requirement is to be able to redirect certain URI's to our company's enterprise portal. Has anybody used this setup in production ? Does anybody know of a...

if i like Ruby a lot, is there a reason I should learn another language now, such as Lua or Erlang?

if i like Ruby a lot, is there a reason I should learn another language now, such as Lua or Erlang? ...

Erlang as a backend process

I want to use Erlang for some background processing and stuff for a web app. I read about its concurrency handling and stuff and I have started learning it. What I want to do specifically is a persistent connection with the clients using COMET - with the Erlang process co-ordinating the HTTP client connections. Do I need a Erlang base...

sha256 encryption in erlang

Hi, i have written some code in php there i have use mhash(MHASH_SHA256, $key) and its giving result as expected.i wanna know how we can achieve same thing in erlang.i can see in crypto their is one inbuild sha function is their but i dont think so its mean for sha256. any suggestion what i have to do ? thank you in advance. ...

Erlang: priority receive

Hello, Priority receive in Erlang can easily be implemented as follows: prio() -> receive {priority, X} -> X after 0 -> receive X -> X end end. I am reading a paper called Priority Messaging made Easy in which they describe the following problem: The main problem with the [code] example [above], is ...

hash_hmac in erlang

hi, i wanna know, is their any way to achieve hash_hmac("sha256", $token, $signkey, true) (php) in erlang? thanx in advance ...

if Expression

hi, can any body tell me how to achieve following if expression in erlang if(a==b) { expression1 }else { expression2 ) thanx in adavnce. ...

hex to 64 Signed Decimal

hi, i have hexdecimal data i have to convert into 64 Signed Decimal data ..so i thought have follwoing step like this. 1.hexadecimal to binary, instead of writing my own code conversion i m using code given in this link http://necrobious.blogspot.com/2008/03/binary-to-hex-string-back-to-binary-in.html bin_to_hexstr(Bin) ...