NRaj
NRaj

Reputation: 77

Boost ASIO TCP: push back to socket buffer

I have an application that reads from TCP sockets, using Boost ASIO asynchronous TCP methods. The streams have end markers, and for my purpose it is more efficient to read chunks of data (instead of read_until) because nearly always I do not cross an end marker.

Just to handle the rare occurrence of reading beyond an end marker, is there a way I can push the extra bytes back into the socket buffer? so that another asynchronous handler can see the full complement? Or, is there a way I can emulate istream::seekg on a socket stream? I searched SO and the web but could not find any clue.

Thanks!

Upvotes: 1

Views: 454

Answers (1)

NRaj
NRaj

Reputation: 77

I figured out that the feature that I asked about is not there (no asio method to push back bytes that have been read). Something that approaches what I wanted is to peek into socket buffer. However, this SO question and Sam Miller's reply to this SO question made me abandon my wishful thinking and to redesign my application where I do not need to either peek or put back.

Upvotes: 1

Related Questions