Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Platform independent socket communication between Java and C++

    Hello forum,
    I would like to build a simple Java server that can receive TCP messages from different endpoints that use Java, C++ or any other language. As far as I know the following message properties are critical: byte order, encoding and number representation. However, I don't know which Java Streams and Writers write Java specific code (like ObjectOutputStream does) and which can be used to communicate with a non-Java endpoint.

    Thanks for any help.

  2. #2
    noctarius is online now Member
    Join Date
    Jun 2012
    Location
    Remscheid, Germany
    Posts
    61
    Rep Power
    0

    Default Re: Platform independent socket communication between Java and C++

    Just have a look for Protobuf, Thrift or Avro (or any similar solution). That is the easiest way.

  3. #3
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Platform independent socket communication between Java and C++

    Thanks, but I want to implement it on my own for learning purposes. I just want to send simple data, that looks like this:

    | command (1 byte) | text of varying length (multiple bytes) | number (2 bytes) |
    Last edited by noodle_variation_187-X; 06-12-2013 at 01:11 PM.

  4. #4
    noctarius is online now Member
    Join Date
    Jun 2012
    Location
    Remscheid, Germany
    Posts
    61
    Rep Power
    0

    Default Re: Platform independent socket communication between Java and C++

    Yeah so where is the problem? You have a clue what you want and it seems that you know what byte-protocols look like so you only miss the classes on Java side? Have a look for DataOutputStream / DataInputStream or if you want a little bit more like defining byteorder you could use ByteBuffers (which are more complex to handle).

  5. #5
    Join Date
    Aug 2011
    Posts
    62
    Rep Power
    0

    Default Re: Platform independent socket communication between Java and C++

    As far as I know DataOutputStream and DataInputStream write Java-specific code into the byte stream, but I'm not really sure.

  6. #6
    noctarius is online now Member
    Join Date
    Jun 2012
    Location
    Remscheid, Germany
    Posts
    61
    Rep Power
    0

    Default Re: Platform independent socket communication between Java and C++

    Nope ObjectOutputStream writes a special header to the stream, DataXStream are just writing bytes as documented in the contract. At least there are other buffer implementation you could use.

Similar Threads

  1. Socket communication
    By 0248991 in forum Networking
    Replies: 7
    Last Post: 05-06-2012, 12:27 PM
  2. Replies: 0
    Last Post: 06-14-2011, 06:51 PM
  3. communication with socket
    By yacin87 in forum Networking
    Replies: 0
    Last Post: 04-08-2010, 11:14 PM
  4. Replies: 2
    Last Post: 09-10-2009, 02:29 PM
  5. Why and how Java is a Platform Independent?
    By gopivista in forum New To Java
    Replies: 7
    Last Post: 09-01-2009, 04:34 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •