Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

C++ Java Interaction

 
Priya Vasudevan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I pass parameters from a C program to a Java code using sockets??
I am able to pass a char[] now,but the value is garbled when it is received by the Java server,which might be because of differences in bytes.Can any of you help me out with a cleaner solution?.
Also,how would I pass Object(Vector,HashMap,etc.) from Java to C via sockets??
Thanks!!
 
Gopal Shah
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Priya Vasudevan:
How do I pass parameters from a C program to a Java code using sockets??

If I understand the question correctly, u r trying to communicate using sockets between a server written in C program, and client written in Java.
If that is the case, then u shouldn't be getting garbled values. I had once communicated with telnet application, initially I also got some junk values, becoz of some problem with socket connection (It is difficult to debug, in such cases), but after making appropriate corrections in the code, it worked fine.
For the 2nd part of your question, refer this link
Interacting with Java from the Native side
regards,
Gopals.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to consider encoding whatever objects you're passing back and forth into XML documents. That way, the receiver would always know which encoding to use and the characters wouldn't get "garbled." Of course, this would bring some added complexity into the applications themselves (having to create/parse XML documents and map them into Java objects or C structs).
 
sachin kotalwar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well try out using SOAP, you will not get garbled values.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!