Created
March 2, 2011 19:00
-
-
Save omarkj/851478 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handle_cast(listen, #state{socket=Socket, rest=Rest} = State) -> | |
case gen_tcp:recv(Socket, 0, 35000) of | |
{ok, Data} -> | |
RestOfData = parse(<<Rest/binary, Data/binary>>), | |
gen_server:cast(?SERVER, listen), | |
State#state{rest=RestOfData}; | |
{error, closed} -> | |
io:format("error, socket closed, do failover? ~n"), | |
gen_server:cast(?SERVER, connect), | |
failover(State); | |
{error, timeout} -> | |
io:format("error, timeout - failover ~n"), | |
gen_server:cast(?SERVER, connect), | |
failover(State); | |
_Other -> | |
io:format("listen - some other error :~p~n", [_Other]), | |
State | |
end, | |
{noreply, NewState}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment