erlang

Using gen_server to encapsulate an mnesia table?

I have a server application made in Erlang. In it I have an mnesia table that store some information on photos. In the spirit of "everything is a process" I decided to wrap that table in a gen_server module, so that the gen_server module is the only one that directly accesses the table. Querying and adding information to that table is ...

ejabberd: is there a way to configure a different "cookie" than "ejabberd" ?

I am building an ejabberd module. I require this module to perform RPC calls to another node on the same LAN (sname). From what I understand, ejabberd configures it owns "cookie" which, of course, will differ from the cookie I use for my other nodes. Is there a way to force ejabberd to use another cookie? EDIT: ejabberd starts its dae...

ejabberd: is there a way to determine if a user is an admin?

I've browsed the module development documentation but I can't find an API that would help me determine if 'user' (i.e. identified through a JID) is allowed administrative access. I understand there is the module 'acl' which looks promising (or probably the answer altogether) but no public API is documented. Should I just assume that th...

Finite State Machine and inter-FSM signaling

Recommendations for languages with native (so no FSM generation tools) support for state machine development and execution and passing of messages/signals. This is for telecoms, e.g implementation of FSMs of this level of complexity. I have considered Erlang, but would love some feedback, suggestions, pointer to tutorials, alternatives,...

Erlang: Why does this fail with a 'badarith' exception?

Is it possible to implement a closure in Erlang? For example, how would I translate this snippet from Scheme? (define (make-adder n) (lamdba (x) (+ x n))) I've tried the following, but I'm clearly missing something. make_adder(n) -> fun (x) -> x + n end. Compiling this gives the error Warning: this expression will fail with...

Best Open source projects in Erlang/OTP for learning

I am new to Erlang and wondering what the best open source projects are out there with good documentation. I completed reading both the books Erlang Programming (Francesco) and Programming Erlang (Joe). From what I can see ErlyWeb (Yariv's web framework) and Mochiweb seems to have good documentation. Given my basic knowledge, are there a...

How build non-blocking TCP server with ssl encryption

Non-blocking TCP server on trapexit.org explains how to build server based on tcp_gen, but i want to modify this example and make it work with ssl. For now i have completely no idea how to replace {ok, Ref} = prim_inet:async_accept(Listen_socket, -1) ...

Erlang lists:index_of function?

I'm looking for an Erlang library function that will return the index of a particular element in a list. So, if X=[10,30,50,70] then lists:index_of(30, X) would return 1, etc., just like java.util.List's indexOf() method. Does such a method exist in the Erlang standard lib? I tried looking in the lists module but no luck. Or shou...

interfacing erlang application with php

Hi, I have a website built with PHP. I have an Erlang application running as a daemon on the same server. I need to call functions on the Erlang application from PHP and get back the result. I've found PHP/Erlang and over PHP modules but I can't install a PHP module on this server, I can only use PHP code. The only way I know to solve...

Getting ctags to include module qualifiers in the tags file for Erlang code

I'm using Exuberant ctags to index Erlang files. The "tags" file contains functions, but they do not have module qualifiers; so I can't search for "module:function", only "function", which may give several results. Do you know a way to get ctags to include module qualifiers in the tags file? Thanks. ...

Parsing \"–\" with Erlang re

I've parsed an HTML page with mochiweb_html and want to parse the following text fragment 0 1 Basically I want to split the string on the spaces and dash character and extract the numbers in the first characters. Now the string above is represented as the following Erlang list [48,32,226,128,147,32,49] I'm trying to split it using...

Speeding up Erlang indexation function

So following on from this question: http://stackoverflow.com/questions/1459152/erlang-listsindexof-function I have the following code which works just fine: -module(test_index_of). -compile(export_all). index_of(Q)-> N=length(Q), Qs=lists:zip(lists:sort(Q), lists:seq(1, N)), IndexFn=fun(X)-> {_, {_, I}}=lists...

Erlang: is there an API to 'epmd' ?

Is there a way to query the name table that epmd daemon manages? The nodes() function isn't very helpful on that front. NOTE: I am looking for an API aside from parsing the output generated through stdout. ...

erlang: UNIX domain socket support?

Is there a way to access UNIX domain sockets (e.g. /var/run/dbus/system_bus_socket ) directly from Erlang without resorting to a third-party driver? ...

what this error means? [Erlang, mochiweb, MySQL]

Hi there, I made a comet chat server with Erlang and Mochiweb. And I run the "./start-dev.sh" to start the server. But after about 1 month I got the following error: =ERROR REPORT==== 26-Sep-2009::09:21:06 === {mochiweb_socket_server,235, {child_error, {badmatch, {error, [70,97,105,108,101,100,32...

is erlangs recursive functions not just a goto?

Hi, Just to get it straight in my head. Consider this example bit of Erlang code: test() -> receive {From, whatever} -> %% do something test(); {From, somethingelse} -> %% do something else test(); end. Isn't the test() call, just a goto? I ask ...

In Erlang, what are the benefits of using ets instead of process dictionary within a process?

I think using ets will still introduce similar side effects. ...

erlang: ei_get_type() : where are the defined constants for the 'type' field?

I am trying to use *ei_get_type()* (ei) but I am having trouble finding where the 'type' field is documented. I've looked in ei.h but all I could find was a list of constants starting with "ERL_". #define ERL_SMALL_INTEGER_EXT 'a' #define ERL_INTEGER_EXT 'b' #define ERL_FLOAT_EXT 'c' #define ERL_ATOM_EXT 'd' #defi...

Mochiweb Port 80

Hello - I am attempting to run BeepBeep through Mochiweb on Port 80. It works if I type sudo ./start_server.sh. Are there any security risks with running Mochiweb like this? If so how to remedy? Thanks! ...

functional programming model efficiency (Erlang specific)

Hi I am a newbie in the Erlang world. When I think of how we need to solve the following problem (and there are a long list of similar ones), I think it's really inefficient because we are speaking of a lot of recursion. Apprently, language like C/Java would not need the clumsy recursion to solve this problem, but with Erlang (I guess ot...