SeekableReadStream is a common C++ class that provides read access to data sources that can be seeked, such as files or sockets. It comes with several useful methods, including the ability to read a specific number of bytes, peek at the next byte without advancing the stream position, and determine the current stream position.
char buffer[10]; stream.read(buffer, 10); // read 10 bytes from the file
2. Reading a socket:
c++
#include
#include
int socketfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
SeekableReadStream stream(socketfd);
char buffer[10];
stream.read(buffer, 10); // read 10 bytes from the socket
```
In both examples, we create a SeekableReadStream object that wraps an input stream (a file in the first case, a socket in the second case). We then use the `read()` method to read a specific number of bytes from the stream into a buffer.
The SeekableReadStream class is part of the Poco C++ Libraries, a collection of open source C++ libraries for building high-performance, scalable, and secure network applications.
C++ (Cpp) SeekableReadStream - 30 examples found. These are the top rated real world C++ (Cpp) examples of common::SeekableReadStream extracted from open source projects. You can rate examples to help us improve the quality of examples.