asynchronous gen_tcp

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Tue Aug 24 21:25:41 CEST 2004


>  My biggest problem right now is that when B is waiting on
> gen_tcp:recv it  can't receive messages from C to send. B needs to
> work in a more async manner.  I seem  to remember seeing something
> like this at some point, but now I can't seem to find it.

I suppose your B process is created with {active, false}, if you use
gen_tcp:recv.

If you don't use that option, then B will get messages like {tcp, Socket,
Data} whenever something comes from the client.

If there is a lot of traffic and you want to be able to tell the client to
slow down a little, you can use {active, once} that will deliver one packet
and then swithch to the passive state. By calling
inet:setopts(Socket,[{active, once}]) at an appropriate time, you can
restart this cycle.

regards,
Vlad



More information about the erlang-questions mailing list