[erlang-questions] accept part of a server

Gamoto <>
Fri Apr 3 11:40:57 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.

What is the better approach and the criteria for chosing (crash, supervision, ...) ?





More information about the erlang-questions mailing list