NCL Community Forum Index
  Home   Login   Register   Help   Memberlist   Search   NCL  

NCL Community Forum Index » Provato Support » Setting port numbers on SMS messages
Post new topic  Reply to topic View previous topic :: View next topic 
Setting port numbers on SMS messages
PostPosted: Thu Aug 17, 2006 2:52 pm Reply with quote
Administrator
Site Admin
Joined: 11 Aug 2004
Posts: 237




Source and destination port numbers (similar to TCP/IP port numbers) can be set on SMS messages. The purpose of this is to direct an SMS message at a specific application on the phone.

The MIDP 2.0 API allows a Java Midlet running on a phone to listen on a configurable port number. When an SMS arrives in on that port number the application is started automatically and the SMS content passed to the application.

A sample Provato client is shown below setting the SMS port numbers (usually the source port number is ignored).

Code:

package ie.ncl.provato.examples;

import ie.ncl.vivato.client.soap.VivatoSoapClient;
import ie.ncl.vivato.client.VivatoClientException;
import ie.ncl.vivato.message.VivatoMessage;
import ie.ncl.vivato.message.SmsAttributes;

public class PortExample
{
    public static void main(String args[]) throws VivatoClientException
    {
        VivatoSoapClient client = new VivatoSoapClient();

        client.setServerUrl("http://localhost:8080/provato/soap");
        client.setApplicationName("portExample");
        client.connect();

        VivatoMessage msg = new VivatoMessage();

        msg.setContentType("text/plain");
        msg.setContent("Hello world!");
        msg.setDestination("+353871234567");

        msg.setStringAttribute(SmsAttributes.SOURCE_PORT,"65535");
        msg.setStringAttribute(SmsAttributes.DESTINATION_PORT,"65534");

        client.sendMessage(msg);
        client.close();
    }
}


Note when a port number is set on a message a header called a User Data Header is placed at the beginning of the text/binary message and contains the source and destination port numbers as shown below in the actual hex dump of the message sent to the phone:

00 00 00 00 01 01 30 38 37 31 32 33 34 35 36 37
00 40 00 00 00 00 00 00 00 00 13 06 05 04 FF FF
FF FE
48 65 6c 6c 6f 20 77 6f 72 6c 64 21
View user's profile Send private message

Setting port numbers on SMS messages
 NCL Community Forum Index » Provato Support
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Post new topic  Reply to topic