#include <AsyncSocketBase.hxx>
|
| | AsyncSocketBase (asio::io_context &ioService) |
| |
| virtual | ~AsyncSocketBase () |
| |
| virtual unsigned int | getSocketDescriptor ()=0 |
| |
| virtual void | registerAsyncSocketBaseHandler (AsyncSocketBaseHandler *handler) |
| |
| virtual asio::error_code | bind (const asio::ip::address &address, unsigned short port)=0 |
| | Note: The following API's are thread safe and queue the request to be handled by the ioService thread.
|
| |
| virtual void | connect (const std::string &address, unsigned short port)=0 |
| |
| virtual void | send (const StunTuple &destination, const std::shared_ptr< DataBuffer > &data) |
| | Note: destination is ignored for TCP and TLS connections.
|
| |
| virtual void | send (const StunTuple &destination, unsigned short channel, const std::shared_ptr< DataBuffer > &data) |
| |
| virtual void | receive () |
| | Overlapped calls to receive functions have no effect.
|
| |
| virtual void | framedReceive () |
| |
| virtual void | close () |
| |
| bool | isConnected () const noexcept |
| |
| asio::ip::address & | getConnectedAddress () noexcept |
| |
| unsigned short | getConnectedPort () const noexcept |
| |
| virtual void | setOnBeforeSocketClosedFp (BeforeClosedHandler fp) |
| |
| virtual void | doSend (const StunTuple &destination, unsigned short channel, const std::shared_ptr< DataBuffer > &data, const std::size_t bufferStartPos=0) |
| | Use these if you already operating within the ioService thread.
|
| |
| virtual void | doSend (const StunTuple &destination, const std::shared_ptr< DataBuffer > &data, const std::size_t bufferStartPos=0) |
| |
| virtual void | doReceive () |
| |
| virtual void | doFramedReceive () |
| |
| virtual void | onConnectSuccess () |
| | Class override callbacks.
|
| |
| virtual void | onConnectFailure (const asio::error_code &e) |
| |
| virtual void | onReceiveSuccess (const asio::ip::address &address, unsigned short port, const std::shared_ptr< DataBuffer > &data)=0 |
| |
| virtual void | onReceiveFailure (const asio::error_code &e)=0 |
| |
| virtual void | onSendSuccess ()=0 |
| |
| virtual void | onSendFailure (const asio::error_code &e)=0 |
| |
| virtual void | start () |
| |
| virtual void | stop () |
| |
| virtual void | handleReadHeader (const asio::error_code &e) |
| |
| virtual void | handleServerHandshake (const asio::error_code &e) |
| |
| virtual void | handleTcpResolve (const asio::error_code &ec, const asio::ip::tcp::resolver::results_type &endpoints) |
| |
| virtual void | handleUdpResolve (const asio::error_code &ec, const asio::ip::udp::resolver::results_type &endpoints) |
| |
| virtual void | handleConnect (const asio::error_code &ec, const asio::ip::tcp::endpoint &endpoint) |
| |
| virtual void | handleClientHandshake (const asio::error_code &ec, const asio::ip::tcp::endpoint &endpoint) |
| |
Definition at line 27 of file AsyncSocketBase.hxx.
◆ BeforeClosedHandler
◆ AsyncSocketBase()
| reTurn::AsyncSocketBase::AsyncSocketBase |
( |
asio::io_context & |
ioService | ) |
|
|
explicit |
◆ ~AsyncSocketBase()
| reTurn::AsyncSocketBase::~AsyncSocketBase |
( |
| ) |
|
|
virtual |
◆ allocateBuffer()
| std::shared_ptr< DataBuffer > reTurn::AsyncSocketBase::allocateBuffer |
( |
size_t |
size | ) |
|
|
static |
◆ asyncConnect()
| void reTurn::AsyncSocketBase::asyncConnect |
( |
asio::ip::tcp::socket & |
socket, |
|
|
const asio::ip::tcp::resolver::results_type & |
endpoints |
|
) |
| |
|
protected |
◆ bind()
◆ channelDataPadding()
Over TCP and TLS, a TURN ChannelData message is padded to a multiple of 4 bytes, the padding not counted in its length (RFC 5766 11.5, RFC 8656 12.5): the padding after one of length bytes.
Definition at line 76 of file AsyncSocketBase.hxx.
◆ close()
| void reTurn::AsyncSocketBase::close |
( |
| ) |
|
|
virtual |
◆ connect()
◆ doFramedReceive()
| void reTurn::AsyncSocketBase::doFramedReceive |
( |
| ) |
|
|
virtual |
◆ doReceive()
| void reTurn::AsyncSocketBase::doReceive |
( |
| ) |
|
|
virtual |
◆ doSend() [1/2]
◆ doSend() [2/2]
Use these if you already operating within the ioService thread.
Definition at line 56 of file AsyncSocketBase.cxx.
◆ framedReceive()
| void reTurn::AsyncSocketBase::framedReceive |
( |
| ) |
|
|
virtual |
◆ getConnectedAddress()
| asio::ip::address & reTurn::AsyncSocketBase::getConnectedAddress |
( |
| ) |
|
|
inlinenoexcept |
◆ getConnectedPort()
| unsigned short reTurn::AsyncSocketBase::getConnectedPort |
( |
| ) |
const |
|
inlinenoexcept |
◆ getSocketDescriptor()
◆ handleClientHandshake()
| virtual void reTurn::AsyncSocketBase::handleClientHandshake |
( |
const asio::error_code & |
ec, |
|
|
const asio::ip::tcp::endpoint & |
endpoint |
|
) |
| |
|
inlinevirtual |
◆ handleConnect()
| virtual void reTurn::AsyncSocketBase::handleConnect |
( |
const asio::error_code & |
ec, |
|
|
const asio::ip::tcp::endpoint & |
endpoint |
|
) |
| |
|
inlinevirtual |
◆ handleReadHeader()
| virtual void reTurn::AsyncSocketBase::handleReadHeader |
( |
const asio::error_code & |
e | ) |
|
|
inlinevirtual |
◆ handleReceive()
| void reTurn::AsyncSocketBase::handleReceive |
( |
const asio::error_code & |
e, |
|
|
size_t |
bytesTransferred |
|
) |
| |
|
protectedvirtual |
◆ handleSend()
| void reTurn::AsyncSocketBase::handleSend |
( |
const asio::error_code & |
e | ) |
|
|
protectedvirtual |
◆ handleServerHandshake()
| virtual void reTurn::AsyncSocketBase::handleServerHandshake |
( |
const asio::error_code & |
e | ) |
|
|
inlinevirtual |
◆ handleTcpResolve()
| virtual void reTurn::AsyncSocketBase::handleTcpResolve |
( |
const asio::error_code & |
ec, |
|
|
const asio::ip::tcp::resolver::results_type & |
endpoints |
|
) |
| |
|
inlinevirtual |
◆ handleUdpResolve()
| virtual void reTurn::AsyncSocketBase::handleUdpResolve |
( |
const asio::error_code & |
ec, |
|
|
const asio::ip::udp::resolver::results_type & |
endpoints |
|
) |
| |
|
inlinevirtual |
◆ isConnected()
| bool reTurn::AsyncSocketBase::isConnected |
( |
| ) |
const |
|
inlinenoexcept |
◆ noteReceived()
| void reTurn::AsyncSocketBase::noteReceived |
( |
| ) |
|
|
inlineprotected |
◆ onConnectFailure()
| virtual void reTurn::AsyncSocketBase::onConnectFailure |
( |
const asio::error_code & |
e | ) |
|
|
inlinevirtual |
◆ onConnectSuccess()
| virtual void reTurn::AsyncSocketBase::onConnectSuccess |
( |
| ) |
|
|
inlinevirtual |
◆ onReceiveFailure()
| virtual void reTurn::AsyncSocketBase::onReceiveFailure |
( |
const asio::error_code & |
e | ) |
|
|
pure virtual |
◆ onReceiveSuccess()
◆ onSendFailure()
| virtual void reTurn::AsyncSocketBase::onSendFailure |
( |
const asio::error_code & |
e | ) |
|
|
pure virtual |
◆ onSendSuccess()
| virtual void reTurn::AsyncSocketBase::onSendSuccess |
( |
| ) |
|
|
pure virtual |
◆ openAndBind()
| asio::error_code reTurn::AsyncSocketBase::openAndBind |
( |
asio::ip::tcp::socket & |
socket | ) |
|
|
protected |
For TCP and TLS client sockets.
openAndBind opens socket and binds it to mLocalTcpEndpoint (set by bind()). asyncConnect connects socket to each of endpoints in turn until one succeeds, then calls handleConnect - like asio::async_connect, but binding the socket before each attempt: asio::async_connect closes it first, losing the binding.
Definition at line 198 of file AsyncSocketBase.cxx.
◆ receive()
| void reTurn::AsyncSocketBase::receive |
( |
| ) |
|
|
virtual |
◆ registerAsyncSocketBaseHandler()
◆ send() [1/2]
Note: destination is ignored for TCP and TLS connections.
Definition at line 32 of file AsyncSocketBase.cxx.
◆ send() [2/2]
◆ setExclusiveAddressUse()
| void reTurn::AsyncSocketBase::setExclusiveAddressUse |
( |
asio::ip::udp::socket & |
socket | ) |
|
|
static |
For a UDP socket, between open() and bind().
UDP sockets don't set SO_REUSEADDR: there's no TIME_WAIT for it to help with, and it would let the socket share a port another socket has (or, on Windows, bind over it), splitting its traffic. On Windows this sets SO_EXCLUSIVEADDRUSE, so neither can another socket - one that sets SO_REUSEADDR - bind over this one.
Definition at line 184 of file AsyncSocketBase.cxx.
◆ setOnBeforeSocketClosedFp()
◆ start()
◆ startIdleTimer()
| void reTurn::AsyncSocketBase::startIdleTimer |
( |
unsigned int |
timeoutSeconds, |
|
|
std::function< bool()> |
inUse |
|
) |
| |
|
protected |
For server connections (TcpConnectionIdleTimeout): the connection is closed, with close(), once nothing has been received on it for timeoutSeconds while inUse() is false - eg.
while it carries no allocation. 0 for no timeout. Call noteReceived() for each message received, and stopIdleTimer() when the connection is stopped.
Definition at line 254 of file AsyncSocketBase.cxx.
◆ stop()
◆ stopIdleTimer()
| void reTurn::AsyncSocketBase::stopIdleTimer |
( |
| ) |
|
|
protected |
◆ mAsyncSocketBaseHandler
◆ mConnected
| bool reTurn::AsyncSocketBase::mConnected |
|
protected |
◆ mConnectedAddress
| asio::ip::address reTurn::AsyncSocketBase::mConnectedAddress |
|
protected |
◆ mConnectedPort
◆ mIOService
| asio::io_context& reTurn::AsyncSocketBase::mIOService |
|
protected |
◆ mLocalTcpEndpoint
| asio::ip::tcp::endpoint reTurn::AsyncSocketBase::mLocalTcpEndpoint |
|
protected |
◆ mOnBeforeSocketCloseFp
Provides an opportunity for the app to clean up, e.g., QoS-related data or resources just before the socket is closed.
Definition at line 134 of file AsyncSocketBase.hxx.
◆ mReceiveBuffer
| std::shared_ptr<DataBuffer> reTurn::AsyncSocketBase::mReceiveBuffer |
|
protected |
◆ mReceiving
| bool reTurn::AsyncSocketBase::mReceiving |
|
protected |
The documentation for this class was generated from the following files: