Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 564235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:44:43+00:00 2026-05-13T12:44:43+00:00

I have a java server that has to communicate over a TCP socket to

  • 0

I have a java server that has to communicate over a TCP socket to an external program written in C. They pass messages back and forth in a message protocol that can’t be changed (due to reasons too complicated to go into here).

The TCP messaging protocol looks roughly like this:

Header (with message length) -> Message body -> Message CRC

It seems to me like this is best handled on the java side with an ObjectInputStream/ObjectOutputStream pair and classes that implement java.io.Serializable and have their own writeObject() and readObject() methods. The problem is that the only solution I can think of for implementing this messaging protocol involves an extra level of indirection that I want to avoid if at all possible.

The diffculty is the write portion of the socket and comes because the message length is in front of the message body. My current solution is to write the message body to a secondary ObjectOutputStream (for the sole purpose of knowing the message length), then writing the header (with length) to the socket, followed by the body then the CRC.

My question is this: is there a better way to do this than to use the temporary ObjectOutputStream? That seems pretty wasteful.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:44:43+00:00Added an answer on May 13, 2026 at 12:44 pm

    Without more details I’d suggest that you shouldn’t be using Object Streams at all they will serialize the Java object to a format that realistically can only been read back into a Java object. Your C program wouldn’t really be able to do anything with what you send it.

    You should probably just be using Byte Array Streams to send the kind of data that the C program can read. You would be able to read the length of the byte array to calculate the CRC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use array_map(), strlen(), max() and func_get_args(): function getLongestString() { $args… May 13, 2026 at 7:20 pm
  • Editorial Team
    Editorial Team added an answer For the sorted dictionary, you can (ab)use the stable nature… May 13, 2026 at 7:20 pm
  • Editorial Team
    Editorial Team added an answer There is no setting on RenderTargetBitmap to tell it to… May 13, 2026 at 7:20 pm

Related Questions

I've got two applications running on two different machines that communicate by sending Serializable
I'm writing an Android App and I'm looking for the fastest (In terms of
I'm not exactly sure what question to ask here since I don't know the
I have a pretty general question here. What is the best + reliable way
Is there a reliable, cross-platform way to do IPC (between two JVMs running on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.