# ConnectionProvider.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
# ConnectionProvider
Simple provider of TCP connections.
namespace oatpp { namespace network { namespace tcp { namespace server {
class ConnectionProvider : public ServerConnectionProvider {}
}}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | ConnectionProvider | Constructor. |
std::shared_ptr<ConnectionProvider> | createShared | Create shared ConnectionProvider. |
[none] | ~ConnectionProvider | Virtual destructor. |
void | stop | Close accept-socket. |
provider::ResourceHandle<data::stream::IOStream> | get | Get incoming connection. |
oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::stream::IOStream>&> | getAsync | No need to implement this. |
const network::Address& | getAddress | Get address - oatpp::network::Address. |
# ConnectionProvider::ConnectionProvider
Constructor.
- @param address - oatpp::network::Address.
- @param useExtendedConnections - set
true
to use ConnectionProvider::ExtendedConnection.false
to use oatpp::network::tcp::Connection.
ConnectionProvider(const network::Address& address, bool useExtendedConnections = false)
# ConnectionProvider::createShared
Create shared ConnectionProvider.
- @param address - oatpp::network::Address.
- @param useExtendedConnections - set
true
to use ConnectionProvider::ExtendedConnection.false
to use oatpp::network::tcp::Connection. - @return -
std::shared_ptr
to ConnectionProvider.
static std::shared_ptr<ConnectionProvider> createShared(const network::Address& address, bool useExtendedConnections = false)
# ConnectionProvider::~ConnectionProvider
Virtual destructor.
~ConnectionProvider()
# ConnectionProvider::stop
Close accept-socket.
void stop() override
# ConnectionProvider::get
Get incoming connection.
- @return oatpp::data::stream::IOStream.
provider::ResourceHandle<data::stream::IOStream> get() override
# ConnectionProvider::getAsync
No need to implement this.
For Asynchronous IO in oatpp it is considered to be a good practice to accept connections in a seperate thread with the blocking accept() and then process connections in Asynchronous manner with non-blocking read/write.
It may be implemented later
oatpp::async::CoroutineStarterForResult<const provider::ResourceHandle<data::stream::IOStream>&> getAsync() override
# ConnectionProvider::getAddress
Get address - oatpp::network::Address.
- @return
const network::Address& getAddress() const
# ConnectionProvider::ExtendedConnection
Connection with extra data - ex.: peer address.
namespace oatpp { namespace network { namespace tcp { namespace server {
class ConnectionProvider : public ServerConnectionProvider {
class ExtendedConnection : public oatpp::network::tcp::Connection {}
};
}}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | ExtendedConnection | Constructor. |
oatpp::data::stream::Context& | getOutputStreamContext | Get output stream context. |
oatpp::data::stream::Context& | getInputStreamContext | Get input stream context. |
# ConnectionProvider::ExtendedConnection::ExtendedConnection
Constructor.
- @param handle - oatpp::v_io_handle.
- @param properties - oatpp::data::stream::Context::Properties.
ExtendedConnection(v_io_handle handle, data::stream::Context::Properties&& properties)
# ConnectionProvider::ExtendedConnection::getOutputStreamContext
Get output stream context.
- @return - oatpp::data::stream::Context.
oatpp::data::stream::Context& getOutputStreamContext() override
# ConnectionProvider::ExtendedConnection::getInputStreamContext
Get input stream context.
- @return - oatpp::data::stream::Context.
oatpp::data::stream::Context& getInputStreamContext() override