erlang

Problem stopping an Erlang SSH channel

NOTE: I'll use the ssh_sftp channel as an example here, but I've noticed the same behaviour when using different channels. After starting a channel: {ok, ChannelPid} = ssh_sftp:start_channel(State#state.cm), (where cm is my Connection Manager), I'm performing an operation through the channel. Say: ssh_sftp:write_file(ChannelPid, Fil...

What is the most efficient way to create a web video chat ?

What is the more efficient way to create a web video chat ? What tecnologies ? What server side and client side languages ? What type fo server ? etc . Thanks ;) ...

Using RabbitMQ (Java client), is there a way to determine if network connection is closed during consume?

I'm using RabbitMQ on RHEL 5.3 using the Java client. I have 2 nodes (machines). Node1 is consuming messages from a queue on Node2 using the Java helper class QueueingConsumer. QueueingConsumer consumer = new QueueingConsumer(channel); channel.basicConsume("MyQueueOnNode2", noAck, consumer); while (true) { QueueingConsumer.Delivery...

Uses of Erlang in Telecom

I'm a web developer and a college student majoring in telecommunications. This means I'm decent at programming and I know a little about telecom networks (at a high, non-technical level). I keep reading that Erlang is used all over the telecom industry (supposedly for its performance). I'm wondering if there's anyway I can combine my p...

how to read the contents of a file In Erlang ?

I know you can do something like this: readlines(FileName) -> {ok, Device} = file:open(FileName, [read]), get_all_lines(Device, []). get_all_lines(Device, Accum) -> case io:get_line(Device, "") of eof -> file:close(Device), Accum; Line -> get_all_lines(Device, Accum ++ [Line]) end. : Is there a one li...

Determining if an item is a string or a list in Erlang

I am writing a program that can have either a list or a string as an argument. How can I tell the difference between a string and a list programmatically in Erlang. Something like: print(List) -> list; print(String) -> string. ...

Erlang bit syntax variable issue

Is there any way to format this so it's a valid expression, without adding another step? <<One:8,_:(One*8)>> = <<1,9>>. * 1: illegal bit size These work >> <<One:8,_:8>> = <<1,9>>. <<1,9>> >> One*8. 8 >> <<One:8,_:(1*8)>> = <<1,9>>. <<1,9>> >> <<Eight:8,_:Eight>> = <<8,9>>. <<8,9>> I'm trying to parse a binary wi...

Is Pseudo typing in Erlang the way to get types?

For example, to denote a String I could use: {string,"hjggjhhggJ"} and a list would be: {list, [1,2,3]} : I guess I have found that I am running into situations where I need types, for example to distinguish between strings and lists and I am not sure how to proceed. I do however want to use whatever technique I choose everywhere in ...

Adding International support in Erlang Web 1.4

I'm trying to add international support for a website based on the Erlang Web 1.4. I would like to have a couple of links on every page (the notorious Country flags) that allow the user to set his language session variable. What I have right now is a link like: <li><a href="/session/language/en">English</a></li> Where, in the sessio...

Retrieving values from Env in mod_esi or webtools

A complete noob question, but how exactly do I get values (e.g. path_info) from inside the callback? From the docs, I thought it was a list of tuples, which I thought would make it accessible via lists:keyfind, but I've had no luck. So far, all the examples I've found only show how to print everything with io_lib but not how to access ...

Log errors in a file

How do I log all process crashes into a file instead of a tty ? I've read in the documentation that there are some standard Erlang modules that can do it (SASL, error_logger), but unfortunately haven't found any clean examples. ...

Records in a guard

I'm attempting to use a record in a guard as described here[1]. If I use the short form described there: handle(Msg, State) when Msg==#msg{to=void, no=3} -> ... I never get a match... however, if I fully expand it to: handle(Msg, State) when Msg#msg.to==void, Msg#msg.no==3 -> ... all is well. As it seems I do with most erlang do...

In Erlang how can I compile a module from within a module?

I have tried : c(module_name). : but this only works from the shell, and gives an error when I try to run it from within a module. ...

In Erlang how can I import all functions from a module?

I can't figure out how to import all the functions of a module without having to specify the individual functions. ...

Sharing [config] data across modules,functions

I have some configuration data in a config file that I read off disk when the app starts. I need to make that configuration data available to other functions/modules in the application. I started down the path of looking into ets/mnesia to store the data on startup to make it shared among all processes, but then my inner voice cautione...

How do you unbind variables in an interactive Erlang session?

In the Erlang interactive shell you can bind variables to values. If I would like to clear everything and start from scratch without exiting the session and starting a new one, how do I do that? And if I just wanted to re-use a single variable, is it possible to re-bind? ...

Threaded Erlang C-Node(cnode) Interoperability howto?

I am at a point in my Erlang development where I need to create a C-Node (see link for C-Node docs). The basic implementation is simple enough, however, there is a huge hole in the doc. The code implements a single threaded client and server. Ignoring the client for the moment... The 'c' code that implements the server is single threade...

spawn_monitor() and 'DOWN' messages

Is it (theoretically) possible that the process that's been spawn_monitor()'ed exits (with the normal exit or on error) without sending 'DOWN' message to the parent process ? I have a very strange process leakage, it seems like some of the processes do not send 'DOWN' message. I am using Erlang package that comes with Ubuntu 9.10. Maybe ...

erlang io:format, and a hanging web application

While I'm learning a new language, I'll typically put lots of silly println's to see what values are where at specific times. It usually suffices because the languages typically have available a tostring equivalent. In trying that same approach with erlang, my webapp just "hangs" when there's a value attempted to be printed that's not ...

Is there a full REPL for Erlang?

Is there a way to have a full interpreter in Erlang, not just a "shell". Since it is a dynamic language, not being able to define named functions in the interpreter is a little bit disappointing... I suspect that it is because compilation units (modules) must be explicitly compiled for their execution by the VM, but maybe a REPL acting...