Java SMPP library from scratch

368 views Asked by At

I am a newbie at java somewhat and what I would like to do is submit a series of hex values to and smpp simulator by ActiveXperts.

However with the below code I am unable to even see data being sent via wireshark to the simulators port which means I am def doing something wrong.

I got the series of hex values from http://docs.nimta.com/smppv50.pdf. So they should have a valid pdu_header and pdu_body. However the data isn't even going out please advice what steps i missed in java to submit the data.

public class Main {

/**
 * @param args the command line arguments
 */
private static byte[] ba = {0x00, 0x00, 0x00, 0x2F
        ,0x00, 0x00 ,0x00, 0x02
        ,0x00 ,0x00 ,0x00, 0x00
        ,0x00, 0x00,0x00 ,0x01
        ,0x53 ,0x4D, 0x50, 0x50
        ,0x33 ,0x54, 0x45 ,0x53
        ,0x54, 0x00, 0x73, 0x65
        ,0x63, 0x72, 0x65, 0x74
        ,0x30, 0x38, 0x00, 0x53
        ,0x55, 0x42, 0x4D, 0x49
        ,0x54, 0x31, 0x00 ,0x50
        ,0x01, 0x01, 0x00};
public static void main(String[] args) throws IOException {
    // TODO code application logic here

    try {
        Socket socket = new Socket("127.0.0.1", 2775);
        System.out.print("Connected");
        OutputStream out = socket.getOutputStream();
        DataOutputStream dos = new DataOutputStream(out);
        for (int i=0; i< ba.length; i++){
            try {
                out.write(ba[i]);
            }catch  (Exception e){
                System.err.println("Don't know about host: taranis.");
            }
        }
        out.flush();
        out.close();

    } catch (UnknownHostException e) {
        System.err.println("Don't know about host: taranis.");
        System.exit(1);
    } catch (IOException e) {
        System.err.println("Couldn't get I/O for "
                           + "the connection to: taranis.");
        System.exit(1);
    }


}

}

0

There are 0 answers