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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:23:08+00:00 2026-05-29T09:23:08+00:00

I use boost::asio::read (or may be the equivalent async_read ) to read some data

  • 0

I use boost::asio::read (or may be the equivalent async_read) to read some data from a socket.

Is it possible that I leave the bytes read in the underlying socket so that next time I call read on the socket I receive again that data ?

  • 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-29T09:23:09+00:00Added an answer on May 29, 2026 at 9:23 am

    Like Simon said, you can’t do it with boost::asio::read() (or boost::asio::async_read()). However, for read() you could call native_handle() on the socket to get the socket descriptor and then use ::recvmsg() with the MSG_PEEK flag. Similarly, you could call async_read() with null_buffers() as the receive buffer and then use the native_handle()/::recvmsg() trick to peek the data. Check out this section of the boost documentation for how to use null_buffers().

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

Sidebar

Related Questions

I have some socket connection code that makes use of boost::asio which reads from
I am attempting to use boost::asio to read and write from a device on
When using a boost::asio::ip::tcp:socket there are many methods one can use to write/send data.
I am trying to receive data from a server application using boost asio's async_read()
I am using Boost asio 1.48. Is it possible to re-use a single boost::asio::io_service
I'm trying to code a wrapper over a boost::asio::ip::tcp::socket Something like that : class
it is a little bit strange to me that boost.asio doesn`t use basic concept
I am trying to use Boost::asio and async_read to implement a timeout in protocol
I use boost::asio::buffer to send a message using void Send(const std::string& messageData) { socket.async_write(boost::asio::buffer(messageData),
I would try to use the library to use socket Boost.Asio c++ on multiple

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.