端口是Erlang与外部程序通信的一种方式。
下图展现了端口与外部程序交互的方式。

OTP 常用的接口函数:
1、 打开端口
open_port/2
2、 通过端口,向外部程序发送数据
port_command
3、 通过端口,从外部程序接收数据
recieve
end.
4、 关闭端口
port_close/0
"Write an Erlang Port using OTP Principles" 这篇文章,详细讲解了如何通过OTP来编写一个端口应用,并通过这个应用来与外部的程序通信。
http://www.trapexit.org/Writing_an_Erlang_Port_using_OTP_Principles
代码在这里: http://www.kazmier.com/computer/port-howto.tar.gz
本文详细介绍了如何通过OTP接口函数(如open_port、port_command、recieve等)来创建Erlang端口,并利用该端口与外部程序进行通信的过程。包括端口的打开、关闭及数据的发送与接收。
153

被折叠的 条评论
为什么被折叠?



