[Erlang危机](5.1.4)端口port

原创文章,转载请注明出处:服务器非业余研究http://blog.csdn.net/erlib 作者Sunface

联系邮箱:[email protected]

Port

In a manner similar to processes, Ports should be considered. Ports are a datatype that encompasses all kinds of connections and sockets opened to the outside world: TCP sockets, UDP sockets, SCTP sockets, file descriptors, and so on.
?There is a general function (again, similar to processes) to count them: length(erlang:ports()) . However, this function merges in all types of ports into a single entity. Instead, one can use recon to get them sorted by type:

端口(ports)和进程的行为模式是很相近的,是一种包含了连接和sockets的数据类型:TCP sockets,UDP sockets,SCTP sockets,文件描述符等等。
?有一个通用的函数(和进程的processes()类似)来计算端口总数量:length(erlang:ports())。但这个函数的输出包含了所有的端口类型的总和,因此你无法获知某个特定类型端口的具体数目,可以使用recon的port_type来根据端口类型排序他们。---------------------------------------------------------
1> recon:port_types().
[{"tcp_inet",21480},
{"efile",2},
{"udp_inet",2},
{"0/1",1},
{"2/2",1},
{"inet_gethost 4 ",1}]
--------------------------------------------------------
?This list contains the types and the count for each type of port. The type name is a string and is defined by the Erlang VM itself.
?All the *_inet ports are usually sockets, where the prefix is the protocol used (TCP, UDP, SCTP). The efile type is for files, while "0/1" and "2/2" are file descriptors for standard I/O channels (stdin and stdout) and standard error channels (stderr), respectively. Most other types will be given names of the driver they’re talking to, and will be examples of port programs 14 or port drivers 15.
?Again, tracking these can be useful to assess load or usage of a system, detect leaks, and so on.?上面这个列表包含了每种类型的端口和数量。端口类型名是Erlang VM自定义的字符串。所有以XXX_inet的端口通常都是sockets,其中XXX前缀就是所使用的协议(TCP,UDP,SCTP)。efile类型是针对文件的,"0/1" 和 "2/2" 就是标准I/O(stdin和stdout),和错误处理(stderr)的文件描述符。大多数其它的port类型在与驱动(dirver)交互时会给定一个名字,代表了相应的port programs14或port drivers15。
   全程跟踪端口数会对诊断负载或进程泄漏有极大的帮助。

[14] http://www.erlang.org/doc/tutorial/c_port.html
[15] http://www.erlang.org/doc/tutorial/c_portdriver.html

[14] http://www.erlang.org/doc/tutorial/c_port.html
[15] http://www.erlang.org/doc/tutorial/c_portdriver.html

时间: 2024-10-10 01:30:54

[Erlang危机](5.1.4)端口port的相关文章

[Erlang危机](2.1)项目结构

?? 原创文章,转载请注明出处:服务器非业余研究http://blog.csdn.net/erlib 作者Sunface Project Structure The structures of OTP applications and of OTP releases are different. An OTP application can be expected to have one top-level supervisor (if any) and possibly a bunch of

[Erlang危机](4.2)Remsh

原创文章,转载请注明出处:server非业余研究http://blog.csdn.net/erlib 作者Sunface 联系邮箱:[email protected] Remsh There's a mechanism entirely similar to the one available through the JCL mode, although invoked in a different manner. The entire JCL mode sequence can by bypa

[Erlang危机](5.1.1)内存

原创文章,转载请注明出处:server非业余研究http://blog.csdn.net/erlib 作者Sunface 联系邮箱:[email protected] Memory The memory reported by the Erlang VM in most tools will be a variant of what is reported by erlang:memory() : Erlang VM大多数检測内存的工具都是通过erlang:memory()来实现的. -----

[Erlang危机](4.0)连接远程节点

原创文章,转载请注明出处:服务器非业余研究http://blog.csdn.net/erlib 作者Sunface 联系邮箱:[email protected] 连接到远程节点 Interacting with a running server program is traditionally done in one of two ways. One is to do it through an interactive shell kept available by using a screen

[Erlang危机](4.1)作业控制模式

原创文章,转载请注明出处:服务器非业余研究http://blog.csdn.net/erlib 作者Sunface 联系邮箱:[email protected] Job Control Mode 作业控制模式 The Job Control Mode (JCL mode) is the menu you get when you press ?G in the Erlang shell. From that menu, there is an option allowing you to con

[Erlang危机](5.0)执行时指标

原创文章.转载请注明出处:server非业余研究http://blog.csdn.net/erlib 作者Sunface 联系邮箱:[email protected] Chapter 5 Runtime Metrics 执行时指标(Runtime Metrics) One of the best selling points of the Erlang VM for production use is how transparent it can be for all kinds of intr

[Erlang危机]Erlang In Danger 序言

原创文章,转载请注明出处:服务器非业余研究http://blog.csdn.net/erlib 作者Sunface?? Introduction On Running Software 运行时软件 There's something rather unique in Erlang in how it approaches failure compared to most other programming languages. There's this common way of thinkin

[Erlang危机](1.3)OTP应用

?? 1.OTP Applications Figuring out OTP applications is usually rather simple. They usually all share a directory structure that looks like: ?搞清楚 OTP applications通常都非常简单,他们通常在同一个目录下, 目标结构如下: doc/;ebin/src/test/LICENSE.txtREADME.mdrebar.config There mi

[Erlang危机](5.1.3)进程

原创文章,转载请注明出处:服务器非业余研究http://blog.csdn.net/erlib 作者Sunface 联系邮箱:[email protected] Processes Trying to get a global view of processes is helpful when trying to assess how much work is being done in the VM in terms of tasks. A general good practice in E