Hassan Syed
Hassan Syed

Reputation: 20485

Same Machine Erlang communication

I need an answer to the following question to help understand what approach I should be taking to interface with Erlang. AFAIK Erlang on a SMP UNIX box uses the multi-process approach. In this case it should do same machine IPC.

  1. Does Erlang use UNIX domain sockets for UNIX ?
  2. Does it use named-pipes for windows ?

  3. If it does not implement both constructs above -- i.e., no named-pipes for windows; it must have to fallback to sockets, on windows.

  4. How are the above mentioned principles implemented, do they use message oriented, single-thread per channel, asynchronous constructs or is it something else ?

  5. If my line of reasoning above is incorrect, does it use a master-child tree and all other processes communicate -- indirectly -- through the master ?

-- edit 1 --

Link to the erlang binary format documentation.

The universal concensus is that Unix Domain Sockets outperform TCP/IP. I think I will try to extend Erlang to use the better primitives provided. I also strongly suspect that epol and windows IOPC is not used in the TCP/IP event loop -- I will post back once I have audited the code.

Another SO post that asserts that Erlang indeed, does not support anything other than TCP and UDP.

There are two Erlang libraries for communication Erlang node -> c_node and c_node -> Erlang_node

The Erlang module for sockets allows Unix Dom Sockets to be opened under UNIX.

Upvotes: 5

Views: 2452

Answers (2)

rvirding
rvirding

Reputation: 20916

As a comment to your original question and to some of the comments:

  • I am VERY sure, in fact I KNOW, that internally within a node the Erlang VM does not use sockets or pipes for communication between (Erlang) processes. That would be ludicrous and completely go against the basic Erlang principles of light-weight inter- (Erlang) process communication.

  • Between Erlang nodes the Erlang VM uses TCP/IP. The semantics and behaviour as seen from Erlang are the same as for intra-node communication, in most respects it is completely transparent on which nodes the processes involved lie.

  • SMPs don't change these basics, irrespective of how many cores and schedulers are used, and irrespective of how many schedulers are run per core.

Upvotes: 14

jldupont
jldupont

Reputation: 96736

R1. It uses TCP/IP (in fact, there isn't any "standard" support for UNIX domain sockets)

R2. I am pretty sure it is still TCP/IP sockets

R3. see R2

R4. There is a binary exchange format proper to Erlang and it is message based. Exchanges can either be sync (RPC-like) or async.

R5. No master.


As bonus (to help you save time): don't forget to use a registered name (-sname or -name) in order to use inter-node communications (either RPC or whatever).

Upvotes: 0

Related Questions