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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:52:39+00:00 2026-05-19T21:52:39+00:00

I have a client that sends me data using this function: void CServerRetrieve::Send(char *buf,

  • 0

I have a client that sends me data using this function:

void CServerRetrieve::Send(char *buf, DWORD size, int flags)
{
    unsigned char *zlib;
    unsigned long szzlib;
    m_zlib.Deflate((unsigned char*)buf, size + 1, &zlib, &szzlib); // include the terminating 0 char
    char zbuf[5];
    zbuf[0] = 'Z';
    memcpy(&zbuf[1], &szzlib, 4);
    send(m_Socket, zbuf, 5, flags);
    send(m_Socket, (char*)zlib, szzlib, flags);
    delete [] zlib;
}

I want to receive this data using Boost::asio, however I am not sure what type of buffer I should pass to socket.async_receive in order for it to receive this data?

I have tried a std::vector<char> and std::vector<std::string>, however no data is ever received in my buffer?

Can someone assist me as to what I’m doing wrong?

void tcp_connection::start()
{
    socket_.async_receive(boost::asio::buffer(buff), boost::bind(&tcp_connection::handle_read, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}

void tcp_connection::handle_read(const boost::system::error_code& err, size_t bytes_transferred)
{
    if (!err || err ==  boost::asio::error::message_size)
    {
        size_t sz = buff.size(); //always 0!
    }
}
  • 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-19T21:52:40+00:00Added an answer on May 19, 2026 at 9:52 pm

    The fact that you are receiving compressed data really does not matter to Boost.Asio. Assuming you you know the size of the data you are about to receive, a std::vector<char> is fine for receiving the compressed data. You’ll need to resize it prior to invoking async_receive Just make sure this buffer does not go out of scope until the completion handler is invoked. This concept is explained int the async_read documentation.

    buffers

    One or more buffers into which the data will be read. The sum
    of the buffer sizes indicates the
    maximum number of bytes to read from
    the stream. Although the buffers
    object may be copied as necessary,
    ownership of the underlying memory
    blocks is retained by the caller,
    which must guarantee that they remain
    valid until the handler is called
    .

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

Sidebar

Related Questions

I have a client server application that sends XML over TCP/IP from client to
I have a client that wants to send a large number of SOAP Header
I have a client that wants the application to be able to send SMS
I have client application that uses WCF service to insert some data to backend
I have an object in Javascript that looks like this function MyObject(){ this.name=; this.id=0;
I have a SQL Server 2008 procedure that sends email via sp_send_dbmail. I'm using
I have a long running query that returns a large data set. This query
Hi guys i have an issue currently when using a Socket to send data.
We have a client that has Oracle Standard , and a project that would
I have a client that is asking me to give them a listing of

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.