gen_tcp and message handling

Fredrik Thulin ft@REDACTED
Thu Jan 6 12:36:57 CET 2005


On Thursday 06 January 2005 12.09, Tony Rogvall wrote:
> 2005-01-06 kl. 11.15 skrev Fredrik Thulin:
> > On Thursday 06 January 2005 04.36, James Hague wrote:
> > ...
> >
> >> gen_tcp:connect?  The main reason I'm asking is that it would be
> >> nice to register the Erlang port returned by gen_tcp:connect, then
> >> send messages to that name, rather than having to pass the TCP
> >> port number all around.
> >
> > It would be terribly easy for you to spawn a process that has a
> > reference to the TCP socket, registers itself and turn signals you
> > send it into gen_tcp:send().
>
> It is very easy, but slower !

I trust you know better than me, but could you be a bit more elaborate 
as to why it is slower? I would guess it would only be marginally 
slower to do

  Process -- signal --> registered process --> gen_tcp:send -> Socket

than to have Socket be a process itself that can be signalled, and have

  Process -- signal --> Socket process

but maybe I'm missing something. Maybe gen_tcp:send() is actually a 
signal to a process already. Then I would agree with you that it would 
actually make a difference. I have to read the source ;)

/Fredrik



More information about the erlang-questions mailing list