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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:05:21+00:00 2026-05-26T12:05:21+00:00

The data between these two functions is becoming garbled. Inspecting the variables on each

  • 0

The data between these two functions is becoming garbled. Inspecting the variables on each side show that the data is definitely different. The message size signal does work. It’s the second read/write function that has the problem.
Here is my write function and its counter read function:

string Pipe::RecvCompressedMessage()
{
int message_size = 0;
DWORD dwBytesRead = 0;
string buf, data;
byte size_in[sizeof(int)];

if (!ReadFile(_h, &message_size, sizeof(int), &dwBytesRead, NULL))
{
    debug->DebugMessage(Error::GetErrorMessageW(GetLastError()));
    Close();
    return "";
}

if (message_size < 0)
    return "";

buf.resize(message_size);

int total_bytes_read = 0;

while(total_bytes_read < message_size)
{
    if (!ReadFile(_h, (LPVOID) &buf, message_size - total_bytes_read, &dwBytesRead, NULL))
    {
        int err = GetLastError();

        debug->DebugMessage(Error::GetErrorMessageW(GetLastError()));
        Close();
        return "";
    }

    data.append(buf);

    total_bytes_read += dwBytesRead;
}

std::string decompressed;
boost::iostreams::filtering_streambuf<boost::iostreams::output> out;
out.push(boost::iostreams::bzip2_decompressor());
out.push(boost::iostreams::back_inserter(decompressed));
boost::iostreams::copy(boost::make_iterator_range(buf), out);

return decompressed;
}


void Pipe::SendCompressedMessage(string message)
{
std::string compressed;
boost::iostreams::filtering_streambuf<boost::iostreams::output> out;
out.push(boost::iostreams::bzip2_compressor());
out.push(boost::iostreams::back_inserter(compressed));
boost::iostreams::copy(boost::make_iterator_range(message), out);

DWORD dwBytesWritten;
int message_size = compressed.length();

if (WriteFile(_h, &message_size, sizeof(int), &dwBytesWritten, NULL) == 0)
{
    debug->DebugMessage(Error::GetErrorMessageW(GetLastError()));

    Close();
    return;
}

if (WriteFile(_h, (LPVOID *) &compressed, message_size, &dwBytesWritten, NULL) == 0)
{
    debug->DebugMessage(Error::GetErrorMessageW(GetLastError()));

    Close();
    return;
}
}
  • 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-26T12:05:22+00:00Added an answer on May 26, 2026 at 12:05 pm

    You are writing a std::string instead a char *:

    if (WriteFile(_h, (LPVOID *) (compressed.c_str()), message_size, &dwBytesWritten, NULL) == 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a difference (performance, overhead) between these two ways of merging data sets?
How to share data between different threads In C# without using the static variables?
I’m using SSIS to synchronize data between two databases. I’ve used SSIS and DTS
I was wondering the difference between these two dispatchEvent method... //1. eventObj:YouTubeSearchEvent = new
I'm currently working on a class that calculates the difference between two objects. I'm
How to pass variable between two functions in same controller? Do I need to
I've got a function that creates two tables. I've made every variable between the
I'am filling tables in .net DataSet with data. There is a nested relation between
I want to transfer data between a smart phone app and a website. What
I'm passing data between my controller and my view using a ViewModel class. When

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.