join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
tls_wrapper.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_CRYPTO_TLS_WRAPPER_HPP
26#define JOIN_CRYPTO_TLS_WRAPPER_HPP
27
28// libjoin.
29#include <join/tls.hpp>
30
31namespace join
32{
36 template <class Protocol>
37 class BasicTlsWrapper : public BasicTls<Protocol>
38 {
39 public:
42
44 using BasicTls<Protocol>::BasicTls;
45
50 bool connecting () const noexcept
51 {
52 return this->_socket.connecting ();
53 }
54
60 {
61 return this->_socket.waitConnected ();
62 }
63
69 bool waitConnected (std::chrono::nanoseconds timeout)
70 {
71 return this->_socket.waitConnected (timeout);
72 }
73
79 bool waitConnected (TimePoint deadline)
80 {
81 return this->_socket.waitConnected (deadline);
82 }
83
89 {
90 return this->_socket.waitDisconnected ();
91 }
92
98 bool waitDisconnected (std::chrono::nanoseconds timeout)
99 {
100 return this->_socket.waitDisconnected (timeout);
101 }
102
109 {
110 return this->_socket.waitDisconnected (deadline);
111 }
112
114 using BasicTls<Protocol>::waitHandshake;
115
122 bool waitHandshake (TimePoint deadline) override
123 {
124 if (!this->_socket.waitConnected (deadline))
125 {
126 return false;
127 }
128
129 return BasicTls<Protocol>::waitHandshake (deadline);
130 }
131
137 int canRead () const noexcept
138 {
139 if (this->_ssl)
140 {
141 return SSL_pending (this->_ssl.get ());
142 }
143
144 return this->_socket.canRead ();
145 }
146 };
147
154 template <class Protocol>
155 inline bool operator< (const BasicTlsWrapper<Protocol>& a, const BasicTlsWrapper<Protocol>& b) noexcept
156 {
157 return a.handle () < b.handle ();
158 }
159}
160
161#endif
TLS decorator for stream sockets.
Definition tls_wrapper.hpp:38
bool waitDisconnected()
block until the underlying socket is disconnected.
Definition tls_wrapper.hpp:88
bool waitHandshake(TimePoint deadline) override
block until TLS handshake is finished, giving up at the given time point.
Definition tls_wrapper.hpp:122
bool waitConnected(std::chrono::nanoseconds timeout)
block until the underlying socket is connected, giving up after the given duration.
Definition tls_wrapper.hpp:69
typename BasicTls< Protocol >::TimePoint TimePoint
Definition tls_wrapper.hpp:41
bool waitConnected()
block until the underlying socket is connected.
Definition tls_wrapper.hpp:59
typename BasicTls< Protocol >::Endpoint Endpoint
Definition tls_wrapper.hpp:40
bool waitConnected(TimePoint deadline)
block until the underlying socket is connected, giving up at the given time point.
Definition tls_wrapper.hpp:79
bool waitDisconnected(std::chrono::nanoseconds timeout)
block until the underlying socket is disconnected, giving up after the given duration.
Definition tls_wrapper.hpp:98
int canRead() const noexcept
get the number of readable bytes.
Definition tls_wrapper.hpp:137
bool connecting() const noexcept
check if the underlying socket is connecting.
Definition tls_wrapper.hpp:50
bool waitDisconnected(TimePoint deadline)
block until the underlying socket is disconnected, giving up at the given time point.
Definition tls_wrapper.hpp:108
basic TLS/DTLS decorator.
Definition tls.hpp:54
bool waitHandshake()
block until TLS handshake is finished.
Definition tls.hpp:350
BasicTls(TlsContext ctx, Mode mode=Mode::NonBlocking) noexcept
create a TLS decorator with an internally created socket.
Definition tls.hpp:68
UnderlyingSocket _socket
verify certificate revocation using CRL.
Definition tls.hpp:1199
typename Protocol::Endpoint Endpoint
Definition tls.hpp:60
SslPtr _ssl
TLS handle.
Definition tls.hpp:1205
typename UnderlyingSocket::TimePoint TimePoint
Definition tls.hpp:61
Definition acceptor.hpp:32
bool operator<(const BasicDatagramSocket< Protocol > &a, const BasicDatagramSocket< Protocol > &b) noexcept
compare if socket handle is inferior.
Definition datagram_socket.hpp:394