gen_server and gen_tcp messages

Andrew Lentvorski <>
Thu Jun 15 00:59:38 CEST 2006


Andrew Lentvorski wrote:
> 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.

Sigh, it never fails.  Send a help message and the answer jumps out at 
you.  I should patent that as a help method ...

Yes, there is a way to deal with messages that are unknown to 
gen_server.  Quoting the documentation for gen_server:

Module:handle_info(Info, State) -> Result

This function is called by a gen_server when a timeout occurs or when it 
receives any other message than a synchronous or asynchronous request 
(or a system message).

-a



More information about the erlang-questions mailing list