0

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);
    }


}

}

sqwale
  • 554
  • 3
  • 24
  • It seems this is your server code. Did you connect a client to this running server? Also, please post output/stacktrace. – Wahid Sadik Sep 01 '13 at 15:55
  • There is no stack trace as no exception was thrown. It just doesn't seem to do anything other than connect to the smpp simulator. It just doesn't send any of the bytes. – sqwale Sep 01 '13 at 16:49
  • I am assuming you are seeing the "Connected" string printed in the console... I would debug and step through the code to see what exactly is happening. – Wahid Sadik Sep 01 '13 at 23:07

0 Answers0