| 1 | #pragma once |
| 2 | |
| 3 | #include <Poco/Net/Socket.h> |
| 4 | |
| 5 | #include <IO/ReadBuffer.h> |
| 6 | #include <IO/BufferWithOwnMemory.h> |
| 7 | |
| 8 | |
| 9 | namespace DB |
| 10 | { |
| 11 | |
| 12 | /** Works with the ready Poco::Net::Socket. Blocking operations. |
| 13 | */ |
| 14 | class ReadBufferFromPocoSocket : public BufferWithOwnMemory<ReadBuffer> |
| 15 | { |
| 16 | protected: |
| 17 | Poco::Net::Socket & socket; |
| 18 | |
| 19 | /** For error messages. It is necessary to receive this address in advance, because, |
| 20 | * for example, if the connection is broken, the address will not be received anymore |
| 21 | * (getpeername will return an error). |
| 22 | */ |
| 23 | Poco::Net::SocketAddress peer_address; |
| 24 | |
| 25 | bool nextImpl() override; |
| 26 | |
| 27 | public: |
| 28 | ReadBufferFromPocoSocket(Poco::Net::Socket & socket_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE); |
| 29 | |
| 30 | bool poll(size_t timeout_microseconds); |
| 31 | }; |
| 32 | |
| 33 | } |
| 34 | |