Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Message Buffers and Data Structures in Java

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Message Buffers and Data Structures in Java

    Hi,
    I am fairly new to java and have an implementation question. I am trying to send/receive a message from a Java GUI through a socket to a process developed in C which will transmit/receive and parse the message. On the C end of the message link, messages will be packed/unpacked using a 16-bit command code (first two bytes of the message) which then tells the parser how the rest of the message data should be interpreted. For instance, this system may have 3 message command codes, A, B and C. Command A will also transmit a integer of data, command B will transmit 2 integers of data and command C will transmit a buffer of 16 chars. On the C end, I would typically use a structure made up of an enum for the command codes and a union of structures to represent the data. This way I can parse the message and populate the data types easily. My question is, what is the best way to implement this message interface in Java? I need to easily pack and unpack messages of various sizes with different message content types as simply as possible. Any suggestions would be greatly appreciated.


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Message Buffers and Data Structures in Java

    There is a ByteBuffer class in jave which is almost like a byte array but already implements functionality to put other data types like Integers, Floats, Doubles, etc inside.

Similar Threads

  1. Data Structures homework help
    By rharvell in forum Java Theory & Questions
    Replies: 1
    Last Post: September 8th, 2013, 08:55 PM
  2. Best way to teach myself Data structures?
    By EatSleepProgram in forum Java Theory & Questions
    Replies: 2
    Last Post: August 12th, 2013, 05:47 AM
  3. Help: Data Structures and Data Types
    By TheLawG14 in forum Java Code Snippets and Tutorials
    Replies: 2
    Last Post: July 19th, 2013, 09:55 AM
  4. data structures question
    By hwoarang69 in forum Algorithms & Recursion
    Replies: 2
    Last Post: November 4th, 2012, 03:07 PM
  5. Please help about data structures.
    By bruce88 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 16th, 2012, 04:11 PM