gen_server and gen_tcp messages
Andrew Lentvorski
bsder@REDACTED
Thu Jun 15 00:12:17 CEST 2006
How do I make a gen_server compatible with receiving messages from gen_tcp?
What I would like to do is packetize a TCP stream. I want this to be
encapsulated into a server so that I just send packets and receive
packets to the server which handles the rest of the underlying issues.
The problem I have is that I need a receive loop in the gen_server in
order to grab the gen_tcp messages. Currently, I wind up with a
gen_server which the spawns off another process solely to handle the
gen_tcp messages. The gen_server and the tcp grab process then have to
handle bidi coordination messages just like are already implemented by
gen_server. This seems ... wrong. I have almost certainly made a poor
architectural decision somewhere.
Is there a way to convince the gen_server to call some code when it gets
a gen_tcp message or message which it doesn't recognize? Basically I
need to splice some extra message handling code into the existing
gen_server receive loop.
Thanks,
-a
More information about the erlang-questions
mailing list