[erlang-questions] Behaviours in a module
Nuku Ameyibor
nayibor@REDACTED
Tue Feb 17 04:40:02 CET 2015
Hello List ,
Hope everyone is cool.
i noticed a few patterns in some tutorials i was going through and wanted
some insight .
How many application behaviors can you attach to a single module and how
does this affect the behavior of the module .
i saw these examples
-module(a).
-behaviour(application).
-export([start/2, stop/1, start_pool/3)
start(normal, _Args) ->
ppool_supersup:start_link().
.....
%%%%and b below
*-*module(b).
-behaviour(application).
-behaviour(supervisor).
-export([start/2, stop/1]).
-export([init/1]).
start() ->application:start(?MODULE).
.......
in module a
i know the start function will call the top level supervisor
and the top level supervisor will start itself and possibly children etc...
in module b
i know the start function will be run and run application:start(?module) .
what happens after that because the function seems to be calling
itself which is causing me to scratch my head .
what happens to the supervisor behavior also .
can you put different behaviors into a single module and evoke them
and make that one module have all the behaviours eg. can a single
module be a gen_server,supervisor or are there some special instances
where this is allowed .(genserver and supervisor both have one init
function so i was beginning to doubt this but what if your behaviors
have different names):
i.e. create your own custom behaviours
an unrelated question
does a socket closing send a message to the controlling process
immediately . i get the {tcp_closed, _Socket} message only when i am
sending a message to a closed socket . it there a way the controlling
process is immediately notified of a closed socket and not nessaringly
when you tring sending a message to it
thanks !!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150217/d78c53aa/attachment.htm>
More information about the erlang-questions
mailing list