MythTV
master
|
Class for communcating between myth backends and frontends. More...
#include <mythsocket.h>
Signals | |
void | CallReadyRead (void) |
Public Member Functions | |
MythSocket (qintptr 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 |
qintptr | m_socketDescriptor {-1} |
QHostAddress | m_peerAddress |
int | m_peerPort {-1} |
MythSocketCBs * | m_callback {nullptr} |
bool | m_useSharedThread |
QAtomicInt | m_disableReadyReadCallback {0} |
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 |
Private Member Functions | |
QString | LOC () |
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 25 of file mythsocket.h.
|
explicit |
Definition at line 71 of file mythsocket.cpp.
|
overrideprotected |
Definition at line 146 of file mythsocket.cpp.
bool MythSocket::ConnectToHost | ( | const QString & | host, |
quint16 | port | ||
) |
connect to host
Definition at line 380 of file mythsocket.cpp.
Referenced by MythCoreContext::ConnectCommandSocket(), ZMClient::connectToHost(), and OutboundRequestHandler::DoConnectToMaster().
bool MythSocket::ConnectToHost | ( | const QHostAddress & | address, |
quint16 | port | ||
) |
Definition at line 293 of file mythsocket.cpp.
void MythSocket::DisconnectFromHost | ( | void | ) |
Definition at line 504 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 409 of file mythsocket.cpp.
Referenced by OutboundRequestHandler::DoConnectToMaster().
|
inline |
Definition at line 41 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
bool MythSocket::Announce | ( | const QStringList & | new_announce | ) |
Definition at line 462 of file mythsocket.cpp.
Referenced by ControlRequestHandler::AnnounceSocket().
|
inline |
Definition at line 44 of file mythsocket.h.
void MythSocket::SetAnnounce | ( | const QStringList & | new_announce | ) |
Definition at line 498 of file mythsocket.cpp.
Referenced by BaseRequestHandler::HandleAnnounce().
|
inline |
Definition at line 46 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
|
inline |
Definition at line 48 of file mythsocket.h.
Referenced by BEFileTransfer::BEFileTransfer(), FileTransfer::FileTransfer(), and PlaybackSock::SendReceiveStringList().
bool MythSocket::SendReceiveStringList | ( | QStringList & | list, |
uint | min_reply_length = 0 , |
||
std::chrono::milliseconds | timeoutMS = kLongTimeout |
||
) |
Definition at line 332 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 319 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 307 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 557 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 563 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 587 of file mythsocket.cpp.
Referenced by MainServer::HandleAnnounce().
int MythSocket::GetPeerPort | ( | void | ) | const |
Definition at line 593 of file mythsocket.cpp.
int MythSocket::GetSocketDescriptor | ( | void | ) | const |
Definition at line 581 of file mythsocket.cpp.
Referenced by FileServerHandler::HandleAnnounce(), MainServer::HandleAnnounce(), and MainServer::ProcessRequest().
int MythSocket::Write | ( | const char * | data, |
int | size | ||
) |
Definition at line 520 of file mythsocket.cpp.
Referenced by FileTransfer::RequestBlock(), BEFileTransfer::RequestBlock(), and RemoteFile::Write().
int MythSocket::Read | ( | char * | data, |
int | size, | ||
std::chrono::milliseconds | max_wait | ||
) |
Definition at line 533 of file mythsocket.cpp.
Referenced by RemoteFile::Read(), ZMClient::readData(), FileTransfer::WriteBlock(), and BEFileTransfer::WriteBlock().
void MythSocket::Reset | ( | void | ) |
Definition at line 547 of file mythsocket.cpp.
Referenced by RemoteFile::Read(), RemoteFile::Reset(), and RemoteFile::SeekInternal().
|
inlineprivate |
Definition at line 74 of file mythsocket.h.
Referenced by AboutToCloseHandler(), Announce(), CallReadyReadHandler(), ConnectHandler(), ConnectToHost(), ConnectToHostReal(), DisconnectFromHost(), DisconnectHandler(), ErrorHandler(), MythSocket(), ReadStringListReal(), ResetReal(), SendReceiveStringList(), WriteStringListReal(), and ~MythSocket().
|
signal |
Referenced by MythSocket(), and ReadyReadHandler().
|
protectedslot |
Definition at line 181 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 232 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 265 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 247 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 270 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 279 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 796 of file mythsocket.cpp.
|
protectedslot |
Definition at line 695 of file mythsocket.cpp.
|
protectedslot |
Definition at line 607 of file mythsocket.cpp.
|
protectedslot |
Definition at line 690 of file mythsocket.cpp.
|
protectedslot |
Definition at line 957 of file mythsocket.cpp.
|
protectedslot |
Definition at line 962 of file mythsocket.cpp.
|
protectedslot |
Definition at line 985 of file mythsocket.cpp.
Referenced by ReadStringListReal().
|
protectedslot |
Definition at line 601 of file mythsocket.cpp.
|
friend |
Definition at line 29 of file mythsocket.h.
|
staticconstexpr |
Definition at line 70 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 71 of file mythsocket.h.
Referenced by MythCoreContext::SendReceiveStringList().
|
protected |
Definition at line 106 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 107 of file mythsocket.h.
Referenced by ConnectToHost(), DisconnectFromHost(), IsDataAvailable(), MythSocket(), Read(), ReadStringList(), Reset(), Write(), WriteStringList(), and ~MythSocket().
|
mutableprotected |
Definition at line 108 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), GetPeerAddress(), GetPeerPort(), GetSocketDescriptor(), and IsConnected().
|
protected |
Definition at line 109 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), and GetSocketDescriptor().
|
protected |
Definition at line 110 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), and GetPeerAddress().
|
protected |
Definition at line 111 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), and GetPeerPort().
|
protected |
Definition at line 112 of file mythsocket.h.
Referenced by CallReadyReadHandler(), ConnectHandler(), DisconnectHandler(), ErrorHandler(), ReadyReadHandler(), SendReceiveStringList(), and ~MythSocket().
|
protected |
Definition at line 113 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().
|
protected |
Definition at line 114 of file mythsocket.h.
Referenced by ReadyReadHandler(), and SendReceiveStringList().
Definition at line 115 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 118 of file mythsocket.h.
Referenced by IsDataAvailable(), IsDataAvailableReal(), ReadReal(), ReadStringListReal(), ReadyReadHandler(), and ResetReal().
Definition at line 119 of file mythsocket.h.
Referenced by Announce(), MythSocketManager::HandleVersion(), and Validate().
Definition at line 120 of file mythsocket.h.
Referenced by Announce(), and SetAnnounce().
|
protected |
Definition at line 121 of file mythsocket.h.
Referenced by Announce(), and SetAnnounce().
|
staticprotected |
Definition at line 123 of file mythsocket.h.
Referenced by ConnectHandler().
|
staticprotected |
Definition at line 125 of file mythsocket.h.
Referenced by ConnectToHostReal().
|
staticprotected |
Definition at line 126 of file mythsocket.h.
Referenced by ConnectToHostReal().
|
staticprotected |
Definition at line 128 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().
|
staticprotected |
Definition at line 129 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().
|
staticprotected |
Definition at line 130 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().