anchor.diff:      {stop, normal, State};
   handle_info({'EXIT', _, Reason}, State) ->
       {stop, Reason, State};
  +handle_info(check_send_deliver_sm, State) ->
  +    case ets:first(get(name)) of
  +        '$end_of_table' ->
  +            self() ! check_send_deliver_sm;
  +        SeqNum ->
  +            [{SeqNum, Body}] = ets:lookup(get(name), SeqNum),
  +            Pdu = {?COMMAND_ID_DELIVER_SM, ?ESME_ROK, SeqNum, Body},
  +            ?SYS_INFO("DELIVER ~p", [Pdu]),
  +            {ok, BinList} = smpp_operation:pack(Pdu),
  +            RespBin = list_to_binary(BinList),
  +            {ok, Reply} = smpp_operation:unpack(RespBin),
  +            ?SYS_INFO("Sending SMPP request: ~p", [smpp:cmd(Reply)]),
  +            send_low(State#state.sock, RespBin)
  +    end,
  +    {noreply, State};
   handle_info(Any, State) ->
       ?SYS_INFO("Unhandled message: ~p", [Any]),
       {noreply, State}.
  
positive.code:     end.
  
  handle_message({CmdId,Status,SeqNum,Body}) ->
      if CmdId band 16#80000000 == 0 ->
             {reply, {CmdId bor 16#80000000, Status, SeqNum, Body}};
         true -> ignore
      end;
  handle_message(Pdu) ->
      {reply, Pdu}.
  
negative.code:         _ -> {PDUs, Buffer}
      end.
  
  handle_data(AutoResponse, Socket, {C,_,SN,B} = Pdu) ->
      case lists:member(C, [?COMMAND_ID_BIND_RECEIVER,
                            ?COMMAND_ID_BIND_TRANSCEIVER,
                            ?COMMAND_ID_BIND_TRANSMITTER]) of
          true ->
              SysId = proplists:get_value(system_id,B),
              TabName = lists:flatten([atom_to_list(?MODULE),"_", SysId]),
              catch ets:new(list_to_atom(TabName), [named_table, public, ordered_set]),
              RegName = list_to_atom(
                          TabName ++
                          case C of
                              ?COMMAND_ID_BIND_RECEIVER -> "_rx";
                              ?COMMAND_ID_BIND_TRANSCEIVER -> "_trx";
                              ?COMMAND_ID_BIND_TRANSMITTER -> "_tx"
                          end),
              erlang:register(RegName, self()),
              put(name, list_to_atom(TabName)),
              if C == ?COMMAND_ID_BIND_RECEIVER ->
                     self() ! check_send_deliver_sm;
                 true -> ok
              end,
              ?SYS_INFO("SMSC : ~p", [RegName]);
          false ->
              if C == ?COMMAND_ID_SUBMIT_SM ->
                     true = ets:insert(get(name), {SN, B});
                 true -> ok
              end
      end,
      ?SYS_INFO("Req : ~p", [smpp:cmd(Pdu)]),
      if AutoResponse == true ->
  