Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Use ASN.1 description to send an integer with socket

Posted on 2013-05-19
2
Medium Priority
?
504 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 1000 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
This video teaches viewers about errors in exception handling.
Suggested Courses

604 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