erlang

How can the “packet” option of socket in Erlang accelerate the tcp transmission so much?

天大地大妈咪最大 提交于 2019-12-23 09:57:15
问题 It takes only 8 seconds to transfer 1G data through two different ports on localhost using {packet,4}, while the same task can't be finished within 30 seconds using {packet,raw}. I know if use the latter method, the data will arrive in tens of thousands small pieces (on archlinux the size is 1460 bytes). I've learned some aspects of TCP/IP protocol and have been thinking about this question for days but still can't figure out what is the EXACT difference. Sincerely look forward to some bottom

Scala, Actors, what happens to unread inbox messages?

独自空忆成欢 提交于 2019-12-23 09:40:56
问题 What happens to unread inbox messages in Scala Actors ? For example two cases: 1.If forget to implement react case for special message: actor!NoReactCaseMessage 2. If messages comes too fast: (timeOfProcessingMessage > timeOfMessageComes) If first or second case happens, would it be stacked in memory? EDIT 1 Is there any mechanism to see this type of memory leak is happening? Maybe, control number of unread messages then make some garbage collect or increase actor pool. How to get number of

What is the standard build tool in Erlang?

南笙酒味 提交于 2019-12-23 08:04:27
问题 I am very new to Erlang programming language. Is there a standard build tool in Erlang? I have googled out these, not sure which one I should use. Erlang Make http://www.erlang.org/doc/man/make.html Rebar Erlang.mk 回答1: Rebar is gradually being replaced by rebar3, which provides more deterministic builds and conflict resolution, packages (integrating with hex.pm), and so on. As one of the current rebar and rebar3 maintainers, I'd recommend rebar3. 回答2: Yes, we can use default make tool for

How to restart child with custom state using Erlang OTP supervisor behaviour?

此生再无相见时 提交于 2019-12-23 07:59:40
问题 I'm using OTP supervisor behaviour to supervise and restart child processes. However when the child dies I want to restart it with the same state it had before the crash. If I write my own custom supervisor, I can just receive {EXIT,Pid,Reason} message and act upon it. When using OTP supervisor behaviour however it is all managed by OTP and I have no control over it. The only callback function I implement is init. Is there any standard approach in case like this? How to customise the state of

Erlang read stdin write stdout

假装没事ソ 提交于 2019-12-23 07:01:10
问题 I'm trying to learn erlang through interviewstreet. I just learning the language now so I know almost nothing. I was wondering how to read from stdin and write to stdout. I want to write a simple program which writes "Hello World!" the number of times received in stdin. So with stdin input: 6 Write to stdout: Hello World! Hello World! Hello World! Hello World! Hello World! Hello World! Ideally I will read the stdin one line at a time (even though it's just one digit in this case) so I think I

Many short-living processes with global process counter

吃可爱长大的小学妹 提交于 2019-12-23 06:29:05
问题 I need to start many short-lived processes to be started by some kind of spawner process, those processes by itselves do some work, save result (or delegate saving to some saver process) and then exit. And there also should be some global limit of the number of parallel running processes. And i suppose some kind of queue, because when limit is reached, then spawner could continue to spawn new processes while they i guess should suspend and wait for the room to run. Could that scheme be

Is it possible to get client's ip address by configuration in rabbitmq's message?

对着背影说爱祢 提交于 2019-12-23 05:34:06
问题 I want to get rabbitmq's client ip address in message. 1. One way is for application to gain it. 2. Anther way is modify rabbitmq's source code to gain it. But is it possible to get it by configuration? 回答1: No, it is not possible to get client ip in message (body or headers) unless you put it there manually. 来源: https://stackoverflow.com/questions/25494920/is-it-possible-to-get-clients-ip-address-by-configuration-in-rabbitmqs-message

ets:foldl vs deleted elements

本小妞迷上赌 提交于 2019-12-23 05:23:04
问题 The documentation for ets:foldl/3 says: If Function inserts objects into the table, or another process inserts objects into the table, those objects may (depending on key ordering) be included in the traversal. But what happens if Function deletes objects from the table? Is there any guarantee that all remaining objects will be included in the traversal in that case? 回答1: According to the source of ets.erl if one process is iterating the table and during that it deletes records those records

looking for a simple ssl erlang example

假如想象 提交于 2019-12-23 05:10:13
问题 in the book "Erlang programming" one of the exercises proposed was to print on screen the request coming from a browser using gen_tcp. I made it for http requests as follows: -module(tcp). -export([server/0, wait_connect/2]). server() -> {ok, ListenSocket} = gen_tcp:listen(1234, [binary, {active, false}]), wait_connect(ListenSocket,0). wait_connect(ListenSocket, Count) -> {ok, Socket} = gen_tcp:accept(ListenSocket), spawn(?MODULE, wait_connect, [ListenSocket, Count+1]), get_request(Socket, []

Erlang needs to connect to https server?

余生颓废 提交于 2019-12-23 03:22:32
问题 I have an erlang application and it needs to connect to a php application hosted on Apache with HTTPS. How do I install the client certificate on my erlang machine? 回答1: The SSL module of Erlang/OTP which is the interface for Secure Socket Layer has an option for defining client side certificate: {cacertfile, path()} Path to a file containing PEM-encoded CA certificates. The CA certificates are used during server authentication and when building the client certificate chain. Now if you want