[erlang-questions] two gen_udp questions

Kaiduan Xie kaiduanx@REDACTED
Sat Aug 8 19:31:31 CEST 2009


Yes, gen_server can receive udp message.

1. Open the socket in the init function of gen_server.
    init() ->

2. The incoming message will be handled in handle_info().

handle_info({udp, Socket, IPtuple, InPortNo, Packet}, State) ->

3. Either way will work.



On Sat, Aug 8, 2009 at 10:18 AM, Micha<micha-1@REDACTED> wrote:
> Hi,
> I have two question about udp handling:
> 1. can a gen_server also receive udp messages? When do I have to open the udp
> port for doing this (start_link, init)?
> 2. if my server receives an udp message and spawns a process to handle the
> request, is it better to let the spawned process sent the answer back over the
> udp socket or should the process sent the answer back to my udp handler which
> in turn sents it over the udp socket to it's destination.
> thanks for answering,
>  Michael
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org

More information about the erlang-questions mailing list