Skip to main content

Transfering a Variable between Java and C++

3 replies [Last post]
simvalue
Offline
Joined: 2008-04-03

Ok this is my first post here and im also a hobby programmer which learned java just recently so please .. yeah .

So my Question is : Can i Use a C++ Programm to send a Variable over the net to a java server and vice versa ... ? I dont see why not ...

Well anyway thanks for your answer in advance ...

sim-value

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fred34
Offline
Joined: 2004-06-19

In a word yes. The programming language is irrelevant when communicating over a network as long as both agree upon the data format.

simvalue
Offline
Joined: 2008-04-03

Thanks !

Means i could even transfer files images and ... objects ?

fred34
Offline
Joined: 2004-06-19

Files, images, whatever you like. It's the data format that counts, if both receiver and server use the same protocol then it doesn't matter. Just a word on objects though, I assume you're talking about one languages specific definition of an Object i.e. Java or C++. The internal representation of Objects in Java is of course specific to Java (and largely hidden from the developer). In order to share Objects between different JVMs on different machines the obvious mechanism is Java Serialization. A quick Google search can give tonnes of examples and explanations. To share objects in a more general way, i.e. across languages and anything else then a more common protocol would be advised. Some quick ideas would be JSON or an XML representation or something of that nature.