The lib_chan Code
Now it’s time for the code.
lib_chan
socket_dist/lib_chan.erl | |
| -module(lib_chan). |
| -export([cast/2, start_server/0, start_server/1, |
| connect/5, disconnect/1, rpc/2]). |
| -import(lists, [map/2, member/2, foreach/2]). |
| -import(lib_chan_mm, [send/2, close/1]). |
| |
| %%---------------------------------------------------------------------- |
| %% Server code |
| |
| start_server() -> |
| case os:getenv("HOME") of |
| false -> |
| exit({ebadEnv, "HOME"}); |
| Home -> |
| start_server(Home ++ "/.erlang_config/lib_chan.conf") |
| end. |
| |
| start_server(ConfigFile) -> |
| io:format("lib_chan starting:~p~n",[ConfigFile]), |
| case file:consult(ConfigFile) of |
| {ok, ConfigData} -> |
| io:format("ConfigData=~p~n",[ConfigData]), |
| case ... |
Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.