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 7794117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:41:42+00:00 2026-06-01T22:41:42+00:00

I have read the docs about http requests and wrote final this headers: int

  • 0

I have read the docs about http requests and wrote final this headers:

int *binary = new int[bufferLength]; // And fill it

std::stringstream out;
out << "POST /push1_pub?id=game HTTP/1.1\r\n";
out << "User-Agent: Lotosoft soccer client\r\n";
out << "Host: localhost\r\n";
out << "Accept: */*\r\n";
out << "Content-Type: application/octet-stream\r\n";
out << "Content-Length: " << bufferLength << "\r\n\r\n";

// Take out string from stream
std::string headers = out.str();
// Length of new array of bytes (headers + binary data + \0)
const int rawLen = headers.size() + bufferLength*sizeof(int) + 1;

char *raw = new char[rawLen];
// Copy headers data into bytes array
strcpy(raw, headers.c_str());
// Apply offset to bytes array and fill another part with binary array of ints
memcpy(raw+headers.size(), binary, bufferLength*sizeof(int));

std::cout << raw << std::endl;

// Send it to socket
if (socket.send(raw, rawLen) == -1)
{
    std::cout << "Failed to send headers\n";
}

Post request sends successfull, but I’m not sure everything is fine with my idea to fill everything into byte array. Is that the right way to pass binary data as post-request body?

  • 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-06-01T22:41:43+00:00Added an answer on June 1, 2026 at 10:41 pm

    Ask yourself this question: “What is the first byte of post data that I send to the server?”. Do you see that you don’t know — it’s whatever your platform happens to store as the first byte of the array, which will depend on how your particular CPU stores integers.

    The server has no idea how your CPU stores integers, so you are sending it information there is no possible way it could make sense out of. You have to send the server a query that consists of bytes in whatever format the server expects, not whatever server your platform likes.

    Also, you tell the server that you are going to send it bufferLength bytes, but then you send it bufferLength*sizeof(int) bytes. You must be consistent. (Presumably, you aren’t on a platform that uses one-byte integers.)

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

Sidebar

Related Questions

I have read this page quite thoroughly: http://datamapper.org/docs/associations If the answer is on there,
I've read some docs about the .NET Garbage Collector but i still have some
I have already read the hibernate docs about concurrency and I think, I have
I have read the Apple docs - http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html#//apple_ref/doc/uid/TP40007457-CH102-SW1 about creating TabBar programmatically. I want
I've read through all of the Spring 3 Web docs: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/spring-web.html but have been
I have read the docs and everything but I'm very confused. I never needed
I have read all the docs I can get my hands on and google'd
I have read through the Rails docs for Routing , Restful Resources , and
I have read some posts on here about not mixing parameters when passing into
I have read that you can do it, but would this really improve performance

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.