1#pragma once
2
3#include <Poco/Net/Socket.h>
4
5#include <IO/WriteBuffer.h>
6#include <IO/BufferWithOwnMemory.h>
7
8
9namespace DB
10{
11
12/** Works with the ready Poco::Net::Socket. Blocking operations.
13 */
14class WriteBufferFromPocoSocket : public BufferWithOwnMemory<WriteBuffer>
15{
16protected:
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
28public:
29 WriteBufferFromPocoSocket(Poco::Net::Socket & socket_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE);
30
31 ~WriteBufferFromPocoSocket() override;
32};
33
34}
35