class http_connection_base - 5cript/attender GitHub Wiki
class http_connection_base
: public attender::http_connection_interface
A http_connection_base provides common functionality for tcp connections.
| Members | Descriptions |
|---|---|
public inline explicit http_connection_base(http_server_interface * parent,SocketT * socket,final_callback const & on_timeout)
|
|
public inline explicit http_connection_base(http_server_interface * parent,SocketT && socket,SocketT &&,final_callback const & on_timeout)
|
|
public inline ~http_connection_base() |
|
public inline virtual void start() |
Starts asynchronous reading. |
public inline virtual void stop() |
Closes the socket and aborts all messaging Also removes the livetime bindings. |
public template<typename IteratorT> inline void write(IteratorT && begin,IteratorT && end,write_callback handler)
|
Gracefully shuts the socket down. |
public inline virtual void write(std::vector< char > && eol_container,write_callback handler) |
A write function for pure data. |
public inline virtual void write(std::vector< char > const & container,write_callback handler) |
This function writes the whole container onto the stream. |
public inline virtual void write(std::istream & stream,write_callback handler) |
This function writes the istream onto the tcp stream. |
public inline virtual void write(std::string const & string,write_callback handler) |
This function writes the string onto the tcp stream. |
public inline virtual void set_read_callback(read_callback const & new_read_callback) |
Sets the read callback, which is called when a read operation finishes. |
public inline virtual void read() |
Read more bytes into the buffer. |
public inline virtual std::size_t ready_count() const |
Returns the amount of bytes that remain in the read buffer. |
public inline virtual buffer_iterator begin() const |
Returns the beginning of the read buffer. |
public inline virtual buffer_iterator end() const |
Returns the end of the read buffer. |
public inline virtual std::vector< char > & get_read_buffer() |
Returns the read buffer. |
public inline virtual http_server_interface * get_parent()
|
Returns the tcp server behind this tcp connection. |
public inline virtual boost::asio::ip::tcp::socket::lowest_layer_type * get_socket() |
Return the associated socket. |
public inline virtual std::string get_remote_address() const |
Returns the remote host address. |
public inline virtual unsigned short get_remote_port() const |
Returns the remote host port. |
protected http_server_interface * parent_
|
|
protected std::unique_ptr< SocketT > socket_ |
|
protected std::vector< char > buffer_ |
|
protected std::vector< char > write_buffer_ |
|
protected read_callback read_callback_inst_ |
|
protected std::size_t bytes_ready_ |
|
protected boost::asio::deadline_timer read_timeout_timer_ |
|
protected std::atomic_bool closed_ |
|
protected std::unique_ptr< lifetime_binding > kept_alive_
|
|
protected final_callback on_timeout_ |
public inline explicit http_connection_base(http_server_interface * parent,SocketT * socket,final_callback const & on_timeout)
public inline explicit http_connection_base(http_server_interface * parent,SocketT && socket,SocketT &&,final_callback const & on_timeout)
Starts asynchronous reading.
Closes the socket and aborts all messaging Also removes the livetime bindings.
public template<typename IteratorT>
inline void write(IteratorT && begin,IteratorT && end,write_callback handler)
Gracefully shuts the socket down.
This function writes all the bytes from begin to end onto the stream. The handler function is called when the write operation completes. Do not (!) call write while another write operation is in progress!
A write function for pure data.
This function assumes that passed data survives the entire ordeal.
This function writes the whole container onto the stream.
The handler function is called when the write operation completes. Do not (!) call write while another write operation is in progress!
This function writes the istream onto the tcp stream.
The handler function is called when the write operation completes. Do not (!) call write while another write operation is in progress!
This function writes the string onto the tcp stream.
The handler function is called when the write operation completes. Do not (!) call write while another write operation is in progress!
Sets the read callback, which is called when a read operation finishes.
Read more bytes into the buffer.
This will overwrite the buffer.
Returns the amount of bytes that remain in the read buffer.
Returns: A number of bytes that can be taken from the buffer.
Returns the beginning of the read buffer.
Returns: An iterator to the read buffer.
Returns the end of the read buffer.
Returns: An iterator to the read buffer.
Returns the read buffer.
Used in request_handler class.
public inline virtual http_server_interface * get_parent()
Returns the tcp server behind this tcp connection.
Do not abuse.
Return the associated socket.
Returns the remote host address.
Returns: empty string on fail, or address on success.
Returns the remote host port.
Returns: 0 on failure, or any other number that is the port (on success).