MythTV
master
|
Class for communcating between myth backends and frontends. More...
#include <mythsocket.h>
Signals | |
void | CallReadyRead (void) |
Public Member Functions | |
MythSocket (qt_socket_fd_t socket=-1, MythSocketCBs *cb=nullptr, bool use_shared_thread=false) | |
bool | ConnectToHost (const QString &hostname, quint16 port) |
connect to host More... | |
bool | ConnectToHost (const QHostAddress &address, quint16 port) |
void | DisconnectFromHost (void) |
bool | Validate (std::chrono::milliseconds timeout=kMythSocketLongTimeout, bool error_dialog_desired=false) |
bool | IsValidated (void) const |
bool | Announce (const QStringList &new_announce) |
QStringList | GetAnnounce (void) const |
void | SetAnnounce (const QStringList &new_announce) |
bool | IsAnnounced (void) const |
void | SetReadyReadCallbackEnabled (bool enabled) |
bool | SendReceiveStringList (QStringList &list, uint min_reply_length=0, std::chrono::milliseconds timeoutMS=kLongTimeout) |
bool | ReadStringList (QStringList &list, std::chrono::milliseconds timeoutMS=kShortTimeout) |
bool | WriteStringList (const QStringList &list) |
bool | IsConnected (void) const |
bool | IsDataAvailable (void) |
QHostAddress | GetPeerAddress (void) const |
int | GetPeerPort (void) const |
int | GetSocketDescriptor (void) const |
int | Write (const char *data, int size) |
int | Read (char *data, int size, std::chrono::milliseconds max_wait) |
void | Reset (void) |
![]() | |
ReferenceCounter (const QString &debugName, bool logDebug=true) | |
Creates reference counter with an initial value of 1. More... | |
virtual int | IncrRef (void) |
Increments reference count. More... | |
virtual int | DecrRef (void) |
Decrements reference count and deletes on 0. More... | |
Static Public Attributes | |
static constexpr std::chrono::milliseconds | kShortTimeout { kMythSocketShortTimeout } |
static constexpr std::chrono::milliseconds | kLongTimeout { kMythSocketLongTimeout } |
Protected Slots | |
void | ConnectHandler (void) |
void | ErrorHandler (QAbstractSocket::SocketError err) |
void | AboutToCloseHandler (void) |
void | DisconnectHandler (void) |
void | ReadyReadHandler (void) |
void | CallReadyReadHandler (void) |
void | ReadStringListReal (QStringList *list, std::chrono::milliseconds timeoutMS, bool *ret) |
void | WriteStringListReal (const QStringList *list, bool *ret) |
void | ConnectToHostReal (const QHostAddress &addr, quint16 port, bool *ret) |
void | DisconnectFromHostReal (void) |
void | WriteReal (const char *data, int size, int *ret) |
void | ReadReal (char *data, int size, std::chrono::milliseconds max_wait_ms, int *ret) |
void | ResetReal (void) |
void | IsDataAvailableReal (bool *ret) const |
Protected Member Functions | |
~MythSocket () override | |
![]() | |
virtual | ~ReferenceCounter (void) |
Called on destruction, will warn if object deleted with references in place. More... | |
Protected Attributes | |
QTcpSocket * | m_tcpSocket {nullptr} |
MThread * | m_thread {nullptr} |
QMutex | m_lock |
qt_socket_fd_t | m_socketDescriptor {-1} |
QHostAddress | m_peerAddress |
int | m_peerPort {-1} |
MythSocketCBs * | m_callback {nullptr} |
bool | m_useSharedThread |
QAtomicInt | m_disableReadyReadCallback {false} |
bool | m_connected {false} |
QAtomicInt | m_dataAvailable {0} |
This is used internally as a hint that there might be data available for reading. More... | |
bool | m_isValidated {false} |
bool | m_isAnnounced {false} |
QStringList | m_announce |
![]() | |
bool | m_logDebug |
This is used to suppress creating LoggingItem classes for LoggingItem reference count changes. More... | |
QAtomicInt | m_referenceCount {1} |
Static Protected Attributes | |
static const int | kSocketReceiveBufferSize = 128 * 1024 |
static QMutex | s_loopbackCacheLock |
static QHash< QString, QHostAddress::SpecialAddress > | s_loopbackCache |
static QMutex | s_thread_lock |
static MThread * | s_thread = nullptr |
static int | s_thread_cnt = 0 |
Friends | |
class | MythSocketManager |
Additional Inherited Members | |
![]() | |
static void | PrintDebug (void) |
Print out any leaks if that level of debugging is enabled. More... | |
Class for communcating between myth backends and frontends.
Definition at line 26 of file mythsocket.h.
|
explicit |
Definition at line 78 of file mythsocket.cpp.
|
overrideprotected |
Definition at line 153 of file mythsocket.cpp.
bool MythSocket::ConnectToHost | ( | const QString & | host, |
quint16 | port | ||
) |
connect to host
Definition at line 387 of file mythsocket.cpp.
Referenced by MythCoreContext::ConnectCommandSocket(), ZMClient::connectToHost(), and OutboundRequestHandler::DoConnectToMaster().
bool MythSocket::ConnectToHost | ( | const QHostAddress & | address, |
quint16 | port | ||
) |
Definition at line 300 of file mythsocket.cpp.
void MythSocket::DisconnectFromHost | ( | void | ) |
Definition at line 511 of file mythsocket.cpp.
Referenced by MythSocketManager::HandleDone(), MainServer::HandleDone(), ZMClient::readData(), MythCoreContext::ResetSockets(), ZMClient::shutdown(), and ~MythSocket().
bool MythSocket::Validate | ( | std::chrono::milliseconds | timeout = kMythSocketLongTimeout , |
bool | error_dialog_desired = false |
||
) |
Definition at line 416 of file mythsocket.cpp.
Referenced by OutboundRequestHandler::DoConnectToMaster().
|
inline |
Definition at line 42 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
bool MythSocket::Announce | ( | const QStringList & | new_announce | ) |
Definition at line 469 of file mythsocket.cpp.
Referenced by ControlRequestHandler::AnnounceSocket().
|
inline |
Definition at line 45 of file mythsocket.h.
void MythSocket::SetAnnounce | ( | const QStringList & | new_announce | ) |
Definition at line 505 of file mythsocket.cpp.
Referenced by BaseRequestHandler::HandleAnnounce().
|
inline |
Definition at line 47 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
|
inline |
Definition at line 49 of file mythsocket.h.
Referenced by FileTransfer::FileTransfer(), and PlaybackSock::SendReceiveStringList().
bool MythSocket::SendReceiveStringList | ( | QStringList & | list, |
uint | min_reply_length = 0 , |
||
std::chrono::milliseconds | timeoutMS = kLongTimeout |
||
) |
Definition at line 339 of file mythsocket.cpp.
Referenced by MythCoreContext::AllowShutdown(), MythCoreContext::BlockShutdown(), RemoteFile::Close(), RemoteFile::GetRealFileSize(), RemoteGetFileList(), FileSystemInfo::RemoteGetInfo(), RemoteSendReceiveStringList(), RemoteFile::ReOpen(), RemoteFile::SeekInternal(), SocketHandler::SendReceiveStringList(), ZMClient::sendReceiveStringList(), PlaybackSock::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), and RemoteFile::SetTimeout().
bool MythSocket::ReadStringList | ( | QStringList & | list, |
std::chrono::milliseconds | timeoutMS = kShortTimeout |
||
) |
Definition at line 326 of file mythsocket.cpp.
Referenced by Announce(), MythCoreContext::CheckProtoVersion(), MythSocketManager::ProcessRequestWork(), MainServer::ProcessRequestWork(), RemoteFile::Read(), PlaybackSock::ReadStringList(), MythCoreContext::readyRead(), SendReceiveStringList(), RemoteEncoder::SendReceiveStringList(), PlaybackSock::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), MythCoreContext::SetupCommandSocket(), Validate(), and RemoteFile::Write().
bool MythSocket::WriteStringList | ( | const QStringList & | list | ) |
Definition at line 314 of file mythsocket.cpp.
Referenced by Announce(), MythCoreContext::CheckProtoVersion(), MainServer::customEvent(), FileServerHandler::HandleAnnounce(), MainServer::HandleAnnounce(), MythSocketManager::HandleVersion(), MainServer::HandleVersion(), MythSocketManager::ProcessRequestWork(), RemoteFile::Read(), SendReceiveStringList(), RemoteEncoder::SendReceiveStringList(), MainServer::SendResponse(), MythCoreContext::SetupCommandSocket(), Validate(), RemoteFile::Write(), and SocketHandler::WriteStringList().
bool MythSocket::IsConnected | ( | void | ) | const |
Definition at line 564 of file mythsocket.cpp.
Referenced by RemoteFile::Close(), MythCoreContext::ConnectToMasterServer(), MainServer::customEvent(), RemoteFile::IsConnected(), ZMClient::readData(), and ~MythSocket().
bool MythSocket::IsDataAvailable | ( | void | ) |
Definition at line 570 of file mythsocket.cpp.
Referenced by CallReadyReadHandler(), MythSocketManager::ProcessRequest(), MainServer::ProcessRequest(), RemoteFile::Read(), PlaybackSock::ReadStringList(), MythCoreContext::readyRead(), and RemoteFile::Write().
QHostAddress MythSocket::GetPeerAddress | ( | void | ) | const |
Definition at line 594 of file mythsocket.cpp.
Referenced by MainServer::HandleAnnounce().
int MythSocket::GetPeerPort | ( | void | ) | const |
Definition at line 600 of file mythsocket.cpp.
int MythSocket::GetSocketDescriptor | ( | void | ) | const |
Definition at line 588 of file mythsocket.cpp.
Referenced by FileServerHandler::HandleAnnounce(), MainServer::HandleAnnounce(), and MainServer::ProcessRequest().
int MythSocket::Write | ( | const char * | data, |
int | size | ||
) |
Definition at line 527 of file mythsocket.cpp.
Referenced by RemoteFile::Write().
int MythSocket::Read | ( | char * | data, |
int | size, | ||
std::chrono::milliseconds | max_wait | ||
) |
Definition at line 540 of file mythsocket.cpp.
Referenced by RemoteFile::Read(), ZMClient::readData(), and FileTransfer::WriteBlock().
void MythSocket::Reset | ( | void | ) |
Definition at line 554 of file mythsocket.cpp.
Referenced by RemoteFile::Read(), RemoteFile::Reset(), and RemoteFile::SeekInternal().
|
signal |
Referenced by MythSocket(), and ReadyReadHandler().
|
protectedslot |
Definition at line 188 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 239 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 272 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 254 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 277 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 286 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 803 of file mythsocket.cpp.
|
protectedslot |
Definition at line 702 of file mythsocket.cpp.
|
protectedslot |
Definition at line 614 of file mythsocket.cpp.
|
protectedslot |
Definition at line 697 of file mythsocket.cpp.
|
protectedslot |
Definition at line 964 of file mythsocket.cpp.
|
protectedslot |
Definition at line 969 of file mythsocket.cpp.
|
protectedslot |
Definition at line 992 of file mythsocket.cpp.
Referenced by ReadStringListReal().
|
protectedslot |
Definition at line 608 of file mythsocket.cpp.
|
friend |
Definition at line 30 of file mythsocket.h.
|
staticconstexpr |
Definition at line 71 of file mythsocket.h.
Referenced by Announce(), RemoteFile::Close(), MythCoreContext::ConnectCommandSocket(), RemoteFile::Read(), RemoteEncoder::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), MythCoreContext::SetupCommandSocket(), and RemoteFile::Write().
|
staticconstexpr |
Definition at line 72 of file mythsocket.h.
Referenced by MythCoreContext::SendReceiveStringList().
|
protected |
Definition at line 99 of file mythsocket.h.
Referenced by Announce(), ConnectHandler(), ConnectToHostReal(), DisconnectFromHostReal(), ErrorHandler(), IsDataAvailable(), IsDataAvailableReal(), MythSocket(), ReadReal(), ReadStringListReal(), ResetReal(), WriteReal(), WriteStringListReal(), and ~MythSocket().
|
protected |
Definition at line 100 of file mythsocket.h.
Referenced by ConnectToHost(), DisconnectFromHost(), IsDataAvailable(), MythSocket(), Read(), ReadStringList(), Reset(), Write(), WriteStringList(), and ~MythSocket().
|
mutableprotected |
Definition at line 101 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), GetPeerAddress(), GetPeerPort(), GetSocketDescriptor(), and IsConnected().
|
protected |
Definition at line 102 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), and GetSocketDescriptor().
|
protected |
Definition at line 103 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), and GetPeerAddress().
|
protected |
Definition at line 104 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), and GetPeerPort().
|
protected |
Definition at line 105 of file mythsocket.h.
Referenced by CallReadyReadHandler(), ConnectHandler(), DisconnectHandler(), ErrorHandler(), ReadyReadHandler(), SendReceiveStringList(), and ~MythSocket().
|
protected |
Definition at line 106 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().
|
protected |
Definition at line 107 of file mythsocket.h.
Referenced by ReadyReadHandler(), and SendReceiveStringList().
Definition at line 108 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), IsConnected(), and MythSocket().
|
mutableprotected |
This is used internally as a hint that there might be data available for reading.
Definition at line 111 of file mythsocket.h.
Referenced by IsDataAvailable(), IsDataAvailableReal(), ReadReal(), ReadStringListReal(), ReadyReadHandler(), and ResetReal().
Definition at line 112 of file mythsocket.h.
Referenced by Announce(), MythSocketManager::HandleVersion(), and Validate().
Definition at line 113 of file mythsocket.h.
Referenced by Announce(), and SetAnnounce().
|
protected |
Definition at line 114 of file mythsocket.h.
Referenced by Announce(), and SetAnnounce().
|
staticprotected |
Definition at line 116 of file mythsocket.h.
Referenced by ConnectHandler().
|
staticprotected |
Definition at line 118 of file mythsocket.h.
Referenced by ConnectToHostReal().
|
staticprotected |
Definition at line 119 of file mythsocket.h.
Referenced by ConnectToHostReal().
|
staticprotected |
Definition at line 121 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().
|
staticprotected |
Definition at line 122 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().
|
staticprotected |
Definition at line 123 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().