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

  • SEARCH
  • Home
  • 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 3974058
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:31:25+00:00 2026-05-20T04:31:25+00:00

I am trying to send the following data to a server, that will be

  • 0

I am trying to send the following data to a server, that will be using C++:

static int user_id; // 4 Bytes
static byte state;  // 1 Byte
static String cipher_data; // 128 Bytes
static String hash;  // 128 Bytes

static final int PACKET_SIZE = 261;

public static byte [] packet = new byte [PACKET_SIZE];

I am trying to create a byte array where I will include all of them:

ByteArrayOutputStream baos = new ByteArrayOutputStream(PACKET_SIZE);
DataOutputStream dos = new DataOutputStream(baos);
dos.write(state);
dos.writeInt(user_id);
for (int i = 0; i < cipher_data.length(); i++) {
    dos.write((byte) cipher_data.charAt(i));
}
for (int i = 0; i < cipher_data.length(); i++) {
    dos.write((byte) hash.charAt(i));
}
packet = baos.toByteArray();

Now I have the byte array with all the data, but I am not sure that what I am doing is correct, and if all this data will be able to be read from the server side. I really will appreciate if you can give me some advise,

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-20T04:31:26+00:00Added an answer on May 20, 2026 at 4:31 am

    First thing you need to care about is the Endian-ness of the source and destination machines.

    Java is Big-Endian

    C++ does not matter, you need to determine what machine (hardware/OS) is the destination program executing on.

    After that, this SO thread shall be able to get you through.

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

Sidebar

Related Questions

I am trying to send data to my server using HttpPost via the following
I'm trying to send an email using swift_smtptransport that will connect to 127.0.0.1:25 I'm
I am trying to send email using c# following is my code. try {
I`m trying to send e-mail via c# and use the following code: public static
I'm trying to connect, using Net::SSH, to a server that immediately after login executes
I am trying to send data, in json format to my webservice, using POST.
I'm trying to send multipart/form-data with following JavaScript and jQuery: var formData = new
I'm trying to retrieve list data from a Sharepoint 2010 server using the webservice
am trying send an array to php file using $_POST ,still always getting an
Trying to send a complex type between two systems that have the same code

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.