gen_server, gen_tcp question

Francesco Cesarini francesco@REDACTED
Wed Jul 17 21:17:10 CEST 2002


>
>
>In the server portion after creating the listen socket
>you would spawn a process whose only job would be to
>accept any incoming connections? 
>
Yes. Once a connection has been accepted, you pass control of that 
socket to a server. (And as Kent said, make sure you handle possible 
incoming packets which might be sent to this process before control has 
been passed).

>I assume that you would not want this process
>to spawn the worker thread to handle the connection,
>considering it should be as simple as possible?
>
More than spawning another process, you would could instead spawn a new 
OTP behavior. It all depends on the nature of your application.

> What
>should it do with an excepted socket then? Message it
>back to the server and let the server handle it? 
>
If you want to allow your server to handle many connections, then the 
answer is yes. Otherwise, if you want one server per connection, than 
you are better off spawning a new behavior.

Regards,
Francesco
--
http://www.erlang-consulting.com




More information about the erlang-questions mailing list