gen_tcp and message handling
Thu Jan 6 11:15:21 CET 2005
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().
In the SIP server I'm working on (Yxa), we do something like this and
also lets the registered process have a list of all TCP connections
that are active so that we can use existing sessions instead of opening
up new ones for every transaction. If you are interested, look a the
sipsocket* modules of the Yxa source.
More information about the erlang-questions