# Interface.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/network/virtual_/Interface.hpp"
# Interface
"Virtual" Interface provides functionality for accepting "virtual" connections. "virtual" connection is represented by oatpp::network::virtual_::Socket.
namespace oatpp { namespace network { namespace virtual_ {
class Interface : public oatpp::base::Countable {}
}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | ~Interface | Destructor. |
std::shared_ptr<Interface> | obtainShared | Obtain interface for given name. |
std::shared_ptr<ListenerLock> | bind | Aquire Interface::ListenerLock. |
std::shared_ptr<ConnectionSubmission> | connect | Connect to interface. |
std::shared_ptr<ConnectionSubmission> | connectNonBlocking | Connect to interface. |
std::shared_ptr<Socket> | accept | Block and wait for incloming connection. |
std::shared_ptr<Socket> | acceptNonBlocking | Check if incoming connection is available. NonBlocking. |
void | dropAllConnection | Drop all waiting connections. |
void | notifyAcceptors | Notify all threads that are waiting on accept(). |
oatpp::String | getName | Get interface name. |
# Interface::~Interface
Destructor.
~Interface()
# Interface::obtainShared
Obtain interface for given name.
- @param name - name of the interface.
- @return -
std::shared_ptr
to Interface.
static std::shared_ptr<Interface> obtainShared(const oatpp::String& name)
# Interface::bind
Aquire Interface::ListenerLock.
- @return -
std::shared_ptr
to Interface::ListenerLock.
std::shared_ptr<ListenerLock> bind()
# Interface::connect
Connect to interface.
- @return - Interface::ConnectionSubmission.
std::shared_ptr<ConnectionSubmission> connect()
# Interface::connectNonBlocking
Connect to interface.
- @return - Interface::ConnectionSubmission on success. Empty
std::shared_ptr
on failure.
std::shared_ptr<ConnectionSubmission> connectNonBlocking()
# Interface::accept
Block and wait for incloming connection.
- @param waitingHandle - reference to a boolean variable. User may set waitingHandle = false and call Interface::notifyAcceptors() in order to break waiting loop. and exit accept() method.
- @param timeout
- @return -
std::shared_ptr
to oatpp::network::virtual_::Socket.
std::shared_ptr<Socket> accept(const bool& waitingHandle = true,
const std::chrono::duration<v_int64, std::micro>& timeout = std::chrono::minutes (10))
# Interface::acceptNonBlocking
Check if incoming connection is available. NonBlocking.
- @return -
std::shared_ptr
to oatpp::network::virtual_::Socket if available. Emptystd::shared_ptr
if no incoming connection is available at the moment.
std::shared_ptr<Socket> acceptNonBlocking()
# Interface::dropAllConnection
Drop all waiting connections.
void dropAllConnection()
# Interface::notifyAcceptors
Notify all threads that are waiting on accept(). Those threads that have waitingHandle changed to false will be unblocked.
void notifyAcceptors()
# Interface::getName
Get interface name.
- @return - oatpp::String.
oatpp::String getName()
# Interface::ListenerLock
ListenerLock
is the Lock object, which represents interface binding ownership.
namespace oatpp { namespace network { namespace virtual_ {
class Interface : public oatpp::base::Countable {
class ListenerLock {}
};
}}}
# Interface::ConnectionSubmission
"Future" for oatpp::network::virtual_::Socket.
namespace oatpp { namespace network { namespace virtual_ {
class Interface : public oatpp::base::Countable {
class ConnectionSubmission {}
};
}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | ConnectionSubmission | Constructor. |
void | setSocket | Set socket to be returned in call to Interface::ConnectionSubmission::getSocket()/Interface::ConnectionSubmission::getSocketNonBlocking(). |
std::shared_ptr<Socket> | getSocket | Block and wait for socket. |
std::shared_ptr<Socket> | getSocketNonBlocking | Check if socket already available. |
bool | isValid | Check if submission is still valid. |
# Interface::ConnectionSubmission::ConnectionSubmission
Constructor.
ConnectionSubmission(bool valid) : m_valid(valid)
# Interface::ConnectionSubmission::setSocket
Set socket to be returned in call to Interface::ConnectionSubmission::getSocket()/Interface::ConnectionSubmission::getSocketNonBlocking().
- @param socket - oatpp::network::virtual_::Socket.
void setSocket(const std::shared_ptr<Socket>& socket)
# Interface::ConnectionSubmission::getSocket
Block and wait for socket.
- @return -
std::shared_ptr
to oatpp::network::virtual_::Socket.
std::shared_ptr<Socket> getSocket()
# Interface::ConnectionSubmission::getSocketNonBlocking
Check if socket already available. User should repeat call if (!socket isPending())
.
- @return -
std::shared_ptr
to oatpp::network::virtual_::Socket.
std::shared_ptr<Socket> getSocketNonBlocking()
# Interface::ConnectionSubmission::isValid
Check if submission is still valid.
- @return -
true
if still valid.
bool isValid()