| 1 | #pragma once |
| 2 | |
| 3 | #include <Poco/Net/Socket.h> |
| 4 | |
| 5 | #include <IO/WriteBuffer.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 WriteBufferFromPocoSocket : public BufferWithOwnMemory<WriteBuffer> |
| 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 | |
| 26 | void nextImpl() override; |
| 27 | |
| 28 | public: |
| 29 | WriteBufferFromPocoSocket(Poco::Net::Socket & socket_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE); |
| 30 | |
| 31 | ~WriteBufferFromPocoSocket() override; |
| 32 | }; |
| 33 | |
| 34 | } |
| 35 | |