<div dir="ltr">I am learning Erlang from Joe's book and one of the thing he teaches is about socket programming. <div>His code example runs like </div><div><table class="" style="margin:0.7em 0px;color:rgb(0,0,0);font-family:verdana,sans-serif;font-size:18px"><tbody><tr style="margin-top:0px;margin-bottom:0px"><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><span class="" style="font-family:DroidSerif;font-weight:bold;font-size:14px"> </span></td><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><div style="white-space:pre-wrap;font-family:DroidSansMono">1><strong class="" style="color:rgb(144,17,125)"> kvs:start().</strong>
</div></td></tr><tr style="margin-top:0px;margin-bottom:0px"><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><span class="" style="font-family:DroidSerif;font-weight:bold;font-size:14px"> </span></td><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><div style="white-space:pre-wrap;font-family:DroidSansMono">true
</div></td></tr><tr style="margin-top:0px;margin-bottom:0px"><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><span class="" style="font-family:DroidSerif;font-weight:bold;font-size:14px"> </span></td><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><div style="white-space:pre-wrap;font-family:DroidSansMono">2><strong class="" style="color:rgb(144,17,125)"> lib_chan:start_server().</strong>
</div></td></tr><tr style="margin-top:0px;margin-bottom:0px"><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><span class="" style="font-family:DroidSerif;font-weight:bold;font-size:14px"> </span></td><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><div style="white-space:pre-wrap;font-family:DroidSansMono">Starting a port server on 1234...
</div></td></tr><tr style="margin-top:0px;margin-bottom:0px"><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><span class="" style="font-family:DroidSerif;font-weight:bold;font-size:14px"> </span></td><td valign="top" class="" style="font-family:DroidSansMono,Mincho;line-height:1.2;font-size:16px;padding-top:0px;padding-bottom:0px"><div style="white-space:pre-wrap;font-family:DroidSansMono">true</div></td></tr></tbody></table></div><div><br></div><div>I try to do the same thing with code he provided </div><div><div>-module(mod_name_server).</div><div>-author("harith").</div><div><br></div><div>%% API</div><div>-export([start_me_up/3]).</div><div><br></div><div>start_me_up(MM, _ArgsC, _ArgsS) -></div><div> loop(MM).</div><div><br></div><div>loop(MM) -></div><div> receive</div><div> {chan, MM, {store, K, V}} -></div><div> kvs:store(K, V),</div><div> loop(MM);</div><div> {chan, MM, {lookup, K}} -></div><div> MM ! {send, kvs:lookup(K)},</div><div> loop(MM);</div><div> {chan_closed, MM} -></div><div> true</div><div> end.</div></div><div><br></div><div><br></div><div>But when I run, I see following </div><div><p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">1> c(kvs).</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">{ok,kvs}</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">2> c(mod_name_server).</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">{ok,mod_name_server}</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">3> kvs:start().</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">true</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">4> lib_chan:start().</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">** exception error: undefined function lib_chan:start/0</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">5> lib_chan_mm:start().</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">** exception error: undefined function lib_chan_mm:start/0</p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54)">6> </p>
<p style="margin:0px;font-size:11px;font-family:Monaco;color:rgb(131,148,150);background-color:rgb(2,43,54);min-height:15px"><br></p></div><div>I even tried for lib_chan_mm, but no luck</div><div><br></div><div>What is going wrong here?</div><div><br></div><div>Thank you</div><div>+ Harit Himanshu </div></div>