Solved

Use ASN.1 description to send an integer with socket

Posted on 2013-05-19
2
480 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 36

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 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