Solved

Use ASN.1 description to send an integer with socket

Posted on 2013-05-19
2
448 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

757 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