Erlang-Interface Technology

Source: Internet
Author: User

The resume interface will be designed for system construction, so that he can be connected to the resume System of applications in different languages. This is called the interface technology of Erlang.

Three methods of interface technology:

1. allow external operating systems to run outside the Erlang virtual machine. This is a safe approach. The code in the real-time external language is also problematic and will not cause the Erlang system to crash. Erlang uses an object named port to control the external program, communication with the outside uses a byte-oriented communication channel. Erlang is responsible for starting and stopping external programs. It can monitor it and restart it after the crash. External processes are called port processes because they are controlled through an Erlang port.

2. Run the operating system command in Erlang and capture the result.

3. it is unsafe to run external language code inside the Erlang Virtual Machine and design external code linked to the Erlang virtual machine code, errors in external language code may cause the Erlang system to crash. Although it is not safe, it is useful because it is more efficient than external code. (When the code is linked to the Erlang kernel, it is only applicable to the language in which the C language can generate the local target code. It is not applicable to languages with virtual machines Like java)

 

How Erlang communicates with external programs

Erlang communicates with an external program through an object named port. If you want to send a message to the port, the message reception will be sent to the external program connected to the port, the message from the external program will become the Erlang message from the port.

For programmers, the port behavior is like an Erlang process. You can send messages to them and register them. If the external program is expanded, an exit signal will be sent to the connected process. If the connected process crashes, the external program will be closed.

Note the difference between using a port and an external process using a socket. If the CIDR block is used, the system wants to use an Erlang to connect to it, send a message to a remote distributed Erlang node. If a socket is used, the process will not behave like this. The process that creates a port is called the connection of this port, the connected process has its special importance. All messages sent to the port must indicate the PID of the connected process. All messages from the external program du hui are sent to the connected process. (To be continued)

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.