[erlang-questions] accept - server

Gamoto <>
Fri Apr 3 18:07:45 CEST 2009


I saw two approaches for the accept part of a server:

Approach 1)
do_accept(LS)->
	case gen_tcp:accept(LS) of
	{ok,S}->spawn(...handle(S)...),
		do_accept(LS);
	Other-> ...
	end.


Approach 2)
do_accept(LS)->
	case gen_tcp:accept(LS) of
	{ok,S}-> spawn(...do_accept(LS) ...),
		 handle(S);
	Other-> ...
	end.

The gen_tcp documentation doesn't explain what is the better approach according criteria (crash of one instance of handle, supervision, etc.)
What is your experience ?




More information about the erlang-questions mailing list