I wrote this ASN.1 description
Demo-module DEFINITIONS ::= -- Module-name DEFINITIONS ::= BEGIN
BEGIN
ClientFirstRequest ::= SEQUENCE {
clientInt INTEGER
}
ServerFirstResponse ::= SEQUENCE {
serverInt INTEGER ,
serverString IA5String
}
ClientSecondRequest ::= SEQUENCE {
clientString IA5String
}
ServerSecondResponse ::= SEQUENCE {
serverResponse IA5String
}
END -- end of module, END required
I have a code who send an integer to a server , it work perfectly
DataOutputStream dos = new DataOutputStream(_socket.getOutputStream());
dos.writeInt(4);
But I tried to use the ASN.1 classes and i have a problem, I tried the following code, but I have an error in the setValue method
ClientFirstRequest h = new ClientFirstRequest();
h.setValue(4);
BerOutputStream bos = new BerOutputStream(_socket.getOutputStream());
h.encode(bos);
This looks like a question you should ask the vendor of the ASN.1 Tool you are using. Each ASN.1 Tool has its own way of going from your values to the encoded byte stream even though the resulting byte stream should be the same for all ASN.1 tools. You have not indicated which ASN.1 Tools you are using.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.