Guest User

Untitled

a guest
Oct 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.41 KB | None | 0 0
  1. connect() ->
  2.     case gen_tcp:connect("localhost", ?PORTS_GATEWAY_TO_CHATNODE, [binary, {active, false}]) of
  3.         exit ->
  4.             ok;
  5.         {ok, Socket} ->
  6.             io:format("[NODE] Connected~n"),
  7.             self() ! online,
  8.             recv(Socket);
  9.  
  10.         {error, Reason} ->
  11.             io:format("[NODE] [ERR] Connect failed: ~p~n", [Reason]),
  12.             receive
  13.                 exit ->
  14.                     io:format("[CONNECT] Exiting~n")
  15.                 after 5000 ->
  16.                     connect()
  17.             end
  18.     end.
Add Comment
Please, Sign In to add comment