anchor.diff:      {next_state, read, State#state{ops=NewOps}, ?TIMEOUT};
   
   read({out, Message}, #state{socket=S} = State) ->
  -    Bytes = list_to_binary(encode(Message)),
  +    Bytes = list_to_binary(ldap_msg:encode(Message)),
       gen_tcp:send(S, Bytes),
       {next_state, read, State, ?TIMEOUT};
   
  
positive.code: read(_Data,  State) ->
      {stop, normal, State}.
  
  decode(Envelope) ->
      case asn1rt:decode('LDAP', 'LDAPMessage', Envelope) of
          {ok, {'LDAPMessage', MessageID, ProtocolOp,_}} ->
  	    {ProtocolOp, MessageID};
  	Error -> {error_decoding, Error}
      end.
  
  encode({ProtocolOp, MessageID}) when is_tuple(ProtocolOp), is_integer(MessageID) ->
      Message = #'LDAPMessage'{messageID = MessageID, protocolOp = ProtocolOp},
      case asn1rt:encode('LDAP', 'LDAPMessage', Message) of
          {ok, Envelope} -> Envelope;
          Error -> {error_encoding, Error}
      end.
  
  handle_event(Event, StateName, State) ->
      {stop, {StateName, undefined_event, Event}, State}.
  
  
negative.code: 
  handle_info({tcp, S, Bin}, StateName, #state{socket=S} = State) ->
      inet:setopts(S, [{active, once}]),
      ?MODULE:StateName({in, ldap_msg:decode(Bin)}, State);
  
  handle_info({tcp_closed,_S}, _StateName, State) ->
      {stop, normal, State};
  