当前位置: 移动技术网 > IT编程>脚本编程>Erlang > Erlang/Elixir精选-第1期

Erlang/Elixir精选-第1期

2019年12月03日  | 移动技术网IT编程  | 我要评论

第1期(20191202)

文章

  1. a short guide to the structure and internals of the erlang distributed messaging facility.
    erlang分布式启动流程源码阅读指南:
    • 节点启动时通过epmd互相发现彼此。
    • net_kernel启动tcp建立稳定的长连接流程,handshake,setnode,set_cookie。
    • 节点间发消息使用的数据格式external term format。
  2. .

    观察节点想启动observer观测其它节点,观察节点只有ssh的网络权限,其它端口不通,
    可以使用把epmd的端口映射ssh代理隧道上,来实现节点通信。
    更进一步,可以研究一下sshex如何通过erlang自带的库来实现功能的。

  3. how to evaluate a string of code in erlang at runtime.

    erlang作为动态语言的绝佳优势就是可以运行时才parse/eval输入的字符串,
    这也是erlang shell运行的基本原理。大部分人都幻想过在浏览器里面运行来
    erlang shell,实现控制管理后台。
    比如这个:tryerlang。可以尝试,但一定要注意如何限制权限。防止被人hack后直接init:stop/0

  4. .

    learn you some erlang_作者fred总结了加入erlang社区10年的变化。。

  5. monitoring erlang atoms.

    原子是不会垃圾回收的,当原子个数达到最大时(默认为1048576),节点会直接crash。
    由于旧版的otp不能直接得到atom数量,所以文中需要间接通过erlang:system_info(info)来做。

    在新版otp中可以直接使用erlang:system_info(atom_limit)和erlang:system_info(atom_count)
    得到最大值和当前值。

$ erl
erlang/otp 20 [erts-9.0] [source] [64-bit] ...
1> [list_to_atom(integer_to_list(i)) 
   || i <- lists:seq(1, erlang:system_info(atom_limit))].
no more index entries in atom_tab (max=1048576)
crash dump is being written to: erl_crash.dump...done

代码

hexadecimal字符转二进制

1> hexs = ["ff","ac","01"].
2> << <<(list_to_integer(c,16)):8>> || c <- hexs >>.
<<255,172,1>>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网