Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Building C language's binary protocol strings in Java

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

One of my fellow researchers (a C/C++ developer) was assigned to design a protocol and because he is a C programmer he designed something which is hard to implement in other languages which we need (VB, php, Java, C#).

If it had built something like SMTP and HTTP protocol (where even numbers are transferred in string format) it could be easily implemented. However he has used C structures.



1) Now the problem is that how can I create such commands (which contain binary coded numbers with different lengths) in Java?

2) What primitive data types I should use for 8bit and 32bit unsigned data types (in a way that later a C program does not have problem interpreting them as normal C data types)?

Thank you for your help.
Mac
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should have no problem writing and reading this with DataOutputStream/DataInputStream. The signed/unsigned issue won't be a problem if handled carefully.
 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic