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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:00:22+00:00 2026-06-16T20:00:22+00:00

I have troubles with sending an array of ints over a socket. the code

  • 0

I have troubles with sending an array of ints over a socket.
the code looks like this

Program 1: (running on windows)

int bmp_info_buff[3];

/* connecting and others */

/* Send informations about bitmap */
send(my_socket, (char*)bmp_info_buff, 3, 0);

Program 2: (running on neutrino)

/*buff to store bitmap information size, with, length */
int bmp_info_buff[3];

/* stuff */

/* Read informations about bitmap */
recv(my_connection, bmp_info_buff, 3, NULL);
printf("Size of bitmap: %d\nwidth: %d\nheight: %d\n", bmp_info_buff[0], bmp_info_buff[1], bmp_info_buff[2]);

It should print
Size of bitmap: 64
width: 8
height: 8

Size of bitmap: 64
width: 6
height: 4096
What do I do wrong?

  • 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-16T20:00:24+00:00Added an answer on June 16, 2026 at 8:00 pm

    When you send the bmp_info_buff array as char array, the size of bmp_info_buff is not 3 but is 3 * sizeof(int)

    The same for recv

    Replace

    send(my_socket, (char*)bmp_info_buff, 3, 0);
    recv(my_connection, bmp_info_buff, 3, NULL);
    

    by

    send(my_socket, (char*)bmp_info_buff, 3*sizeof(int), 0);
    recv(my_connection, bmp_info_buff, 3*sizeof(int), NULL);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some troubles mapping a JSON Array to RestKit. This is what the
I have some troubles with positioning my label/password field. With this code they both
I'm having troubles getting this to work. Basically I have a python program that
I'm writing an MPI C program. I have troubles debugging it, because whenever I
I'm using http://code.google.com/p/django-email-extras/ to generate rich email content. I have trouble in sending email
I have some troubles with the sending of push notifications in a C# multithread
Hi I'm having trouble sending html form array to JS. I have dynamic html
I have troubles with my program when i need to send Strings from my
I have a char (ie. byte) buffer that I'm sending over the network. At
I'm sending a lot of e-mails (like a newsletter) through a web page. This

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.