# 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 base::Countable, 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.
std::shared_ptr<data::stream::IOStream> get Get incoming connection.
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<data::stream::IOStream>&> getAsync No need to implement this.
void invalidate Call shutdown read and write on an underlying file descriptor.
const network::Address& getAddress Get address - oatpp::network::Address.

# ConnectionProvider::ConnectionProvider

Constructor.

ConnectionProvider(const network::Address& address, bool useExtendedConnections = false)

# ConnectionProvider::createShared

Create shared 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.

std::shared_ptr<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 std::shared_ptr<data::stream::IOStream>&> getAsync() override

# ConnectionProvider::invalidate

Call shutdown read and write on an underlying file descriptor. connection MUST be an object previously obtained from THIS connection provider.

  • @param connection

void invalidate(const std::shared_ptr<data::stream::IOStream>& connection) 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 base::Countable, 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.

ExtendedConnection(v_io_handle handle, data::stream::Context::Properties&& properties)

# ConnectionProvider::ExtendedConnection::getOutputStreamContext

Get output stream context.

oatpp::data::stream::Context& getOutputStreamContext() override

# ConnectionProvider::ExtendedConnection::getInputStreamContext

Get input stream context.

oatpp::data::stream::Context& getInputStreamContext() override