我是java的新手,我想做的是向ActiveXperts提交一系列十六进制值和smpp模拟器。
但是,使用下面的代码,我什至看不到通过wireshark发送到模拟器端口的数据,这意味着我做错了什么。
我从http://docs.nimta.com/smppv50.pdf获得了一系列十六进制值。所以他们应该有一个有效的 pdu_header 和 pdu_body。但是数据甚至没有出去,请告知我在java中错过了哪些步骤来提交数据。
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);
}
}
}