Solved

Use ASN.1 description to send an integer with socket

Posted on 2013-05-19
2
453 Views
Last Modified: 2013-05-20
Hello,
this is my 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);

Open in new window


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

Open in new window

image
0
Comment
Question by:alexgaga
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 39178480
Please post link to the javadoc of the API you're using. If i had to guess, you could try

h.clientInt.setValue(4);

Open in new window

0
 
LVL 35

Assisted Solution

by:mccarl
mccarl earned 250 total points
ID: 39180868
Yes, CEHJ is correct above. In your last question I assumed the problem was more to do with writing the object to the outputstream. I didn't look that close at the setValue method call as I assumed from your comment that the code compiled but just didn't give you the correct functionality.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to copy documents folder to network folder automatically as backup? 15 84
custom annotations 9 32
eclipse shortcuts 9 45
reverse digits of a number using for loop 5 36
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now