anchor.diff:    { ok, Q } = beanstalk:connect(),
     { ok, Log } = syslog:open("robot_command_protocol", [ cons, perror, pid ], local3),
     { using, "registration" } = beanstalk:use(Q, registration),
  -  % { watching, _ } = beanstalk:watch(Q, commands),
  +
   	loop(init, Socket, Transport, Q, Log, nil),
  +
  +  % If we get here, that means we have dropped out of the socket
  +  % loop. Close everthing out.
  +
   	ok = Transport:close(Socket),
     syslog:close(Log),
     ok = beanstalk:close(Q).
   
   loop(init, Socket, Transport, Q, Log, _) ->
  +  % Challenge the socket client
     send_message(Socket, Transport, "And You Are?"),
  +  % Wait for response
     case receive_message(Socket, Transport) of
       { ok, Data } ->
         case string:tokens(Data, "|") of
  
positive.code: -module(robot_command_protocol).
  -behavior(ranch_protocol).
  
  
negative.code:   send_messages(Socket, Transport, Messages).
  
  send_message(Socket, Transport, Message) ->
    case Transport:send(Socket, binary:encode_unsigned(length(Message))) of
      ok ->
        Transport:send(Socket, Message);
      Error ->
        Error
    end.
  