Erlang Distributed programming Model

Source: Internet
Author: User

There are two models of Erlang distributed programming

First, distributed Erlang

Running in a trusted network environment

1. Remote procedure call provided by RPC

Rpc:call (Node,mode,fun,args)->result| {Badrpc,reason}

2. Functions in global can be used to register names and locks in distributed systems, and to maintain a fully connected network

Spawn (Node,fun), Pid

Spawn (Node,mode,fun,args)->pid

Spawn_link (Node,fun), Pid

Spawn_link (Node,mode,fun,args)->pid

Disconnect_node (node)->bool () |ignored

Monitor_node (Node,flag)->true

If flag is true, monitoring is turned on, and flag is false to turn off monitoring. If monitoring is turned on, then when
When node joins or leaves the Erlang Interconnect node group, the process that executes the built-in function receives {nodeup, node}
or {nodedown, Node} message.

Nodes ()->[node]

Node ()->node

It returns the name of the local node. If the node is not distributed, it will return [email protected].

Node (ARG)->node

It returns the node where Arg is located. Arg can be a PID, reference, or port. If the local node is not distributed,
[email protected] will be returned.

Is_alive ()->bool ()

Returns true if the local node is active and can be part of a distributed system, otherwise false is returned.

{Regname,node}! Msg

Send can be used to send messages to a set of locally registered processes in a distributed Erlang node

Second, the distributed model based on socket

TCP can password protect services by creating two agent processes, one client, one server side, converting Erlang messages to TCP packet data, and sending and receiving messages over the TCP protocol.

Erlang Distributed programming Model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.