ClickHouse/dbms/include/DB/IO/WriteBufferFromPocoSocket.h
2014-03-07 08:04:02 +04:00

35 lines
888 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <Poco/Net/Socket.h>
#include <DB/IO/WriteBuffer.h>
#include <DB/IO/BufferWithOwnMemory.h>
namespace DB
{
/** Работает с готовым Poco::Net::Socket. Операции блокирующие.
*/
class WriteBufferFromPocoSocket : public BufferWithOwnMemory<WriteBuffer>
{
protected:
Poco::Net::Socket & socket;
/** Для сообщений об ошибках. Нужно получать этот адрес заранее, так как,
* например, если соединение разорвано, то адрес уже будет получить нельзя
* (getpeername вернёт ошибку).
*/
Poco::Net::SocketAddress peer_address;
void nextImpl();
public:
WriteBufferFromPocoSocket(Poco::Net::Socket & socket_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE);
~WriteBufferFromPocoSocket();
};
}