SMS Component - SmppServer object

Overview

The Short Message Peer to Peer protocol (SMPP) is used for sending and receiving SMS messages. It's a TCP/IP based binary application protocol which was specifically developed for high volume, low latency sending of SMS messages. The protocol supports all SMS features like delivery reports / binary SMS messages etc..

The SMPP Server object can be used to listen for incoming SMPP client connections. After starting the SMPP server every client will be represented by an SMPP session object and through these SMPP sessions objects you can receive SMS messages from the client and send SMS messages to the client.

Some advantages for using SMPP instead of a GSM modem:

The SmppServer object features the following:

The SmppServer object is part of the ActiveXperts SMS Component. Overview of all SMS Component objects:

Sample code

VBScript sample: Send and receive SMS messages to/from multiple clients simultaneously

Set objSmppServer = CreateObject("AxSms.SmppServer")   ' Create the SMPP server object
Set objConstants = CreateObject("AxSms.Constants")  ' Create the SMS constants object

' Show version information
Wscript.Echo "SMS Component" & objSmppServer.Version & "; Build " & _
  objSmppServer.Build & "; Module " & objSmppServer.Module
WScript.Echo "Expiration date: " & objSmppServer.ExpirationDate & vbCrLf

objSmppServer.Logfile = "server.log"
objSmppServer.Start 2775
If objSmppServer.LastError <> 0 Then
  WScript.Echo "Error while starting SMPP server: " & _
    objSmppServer.GetErrorDescription(objSmppServer.LastError)
  WScript.Quit 1
End If
WScript.Echo "SMPP server started..."

While objSmppServer.IsStarted
  Set objSmppSession = objSmppServer.GetFirstSession
  While objSmppServer.LastError = 0
    ' Accept all sessions that request a bind
    If objSmppSession.ConnectionState = objConstants.SMPP_SESSIONSTATE_BINDING Then
      WScript.Echo "Client IP: " & objSmppSession.Ip & ":" & objSmppSession.Port
      WScript.Echo "SystemId: " & objSmppSession.SystemId
      WScript.Echo "AddressRange: " & objSmppSession.AddressRange
      objSmppSession.LogFile = objSmppSession.SystemId & ".log"
      objSmppSession.RespondToBind objConstants.SMPP_ESME_ROK
    End If    
    
    If objSmppSession.ConnectionState = objConstants.SMPP_SESSIONSTATE_BOUND_TRX Then
      ' Receive incoming messages
      Set objMessage = objSmppSession.ReceiveSubmitSms
      While objSmppSession.LastError = 0
        WScript.Echo "Receive sms from: " & objSmppSession.SystemId & "; to: " & _
          objMessage.ToAddress & "; suggested reference: " & objMessage.Reference
        
        ' Accept the incoming message with the suggested message reference
        objSmppSession.RespondToSubmitSms objMessage
        If objSmppSession.LastError <> 0 Then
          WScript.Echo "Error while responding: " & _
            objSmppSession.GetErrorDescription(objSmppSession.LastError)
          WScript.Quit 1
        End If
        
        ' Send a successful delivery report for the incoming message
        objMessage.SmppStatus = objConstants.SMPP_MESSAGESTATE_DELIVERED
        objSmppSession.DeliverReport objMessage
        If objSmppSession.LastError <> 0 Then
          WScript.Echo "Error while sending delivery report: " & _
            objSmppSession.GetErrorDescription(objSmppSession.LastError)
          WScript.Quit 1
        End If
        
        Set objMessage = objSmppSession.ReceiveSubmitSms
      WEnd

      ' Deliver a new message to the client
      Set objMessage = CreateObject("AxSms.Message")
      objMessage.ToAddress = "+31122334455"
      objMessage.FromAddress = "+35544332211"
      objMessage.Body = "Hello from the ActiveXperts Gateway !"
      objMessage.UserTag = 1 ' To identify this message when the client responds
      objSmppSession.DeliverSms objMessage
      If objSmppSession.LastError <> 0 Then
        WScript.Echo "Error while delivering: " & _
          objSmppSession.GetErrorDescription(objSmppSession.LastError)
        WScript.Quit 1
      End If
      
      ' Check if the client accepted any messages
      Set objMessage = objSmppSession.ReceiveDeliverResponse
      While objSmppSession.LastError = 0
        WScript.Echo "Response: " & objMessage.SmppCommandStatus & _
          " for UserTag: " & objMessage.UserTag
        Set objMessage = objSmppSession.ReceiveDeliverResponse
      WEnd
    End If
    
    Set objSmppSession = objSmppServer.GetNextSession
  WEnd

  objSmppServer.Sleep 1000
WEnd

objSmppServer.Stop

More samples

Samples are available for: C# .NET, Visual Basic .NET, Visual C/C++, VBA, ASP, ASP .NET, Java, Javascript, PHP, HTML, ColdFusion, Delphi and more.

On ftp.activexperts-labs.com, you can find many SMS Component samples. Samples are also part of the SMS Component installation.