Erlang: is there an API to 'epmd'?

一笑奈何 提交于 2019-12-06 03:49:34

问题


Is there a way to query the name table that epmd daemon manages?

The nodes() function isn't very helpful on that front.

NOTE: I am looking for an API aside from parsing the output generated through stdout.


回答1:


To query nodes visible for epmd, call:

EpmdModule = net_kernel:epmd_module().  % erl_epmd by default
EpmdModule:names().

To get a list of connected nodes and their ports:

erlang:system_info(dist).
erlang:system_info(dist_ctrl).

The first call returns you the table in a crash dump format. If you are interested in acquiring the actual ports, use the second one.




回答2:


You get the same answer as Zed's code by doing:

net_adm:names()

I don't know if that is a more standard way of doing it or not.



来源:https://stackoverflow.com/questions/1478360/erlang-is-there-an-api-to-epmd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!