|
MythTV master
|
Class for communcating between myth backends and frontends. More...
#include <libmythbase/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) |
Public Member Functions inherited from ReferenceCounter | |
| 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 | |
Protected Member Functions inherited from ReferenceCounter | |
| 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 |
Protected Attributes inherited from ReferenceCounter | |
| 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 Public Member Functions inherited from ReferenceCounter | |
| 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 75 of file mythsocket.cpp.
|
overrideprotected |
Definition at line 144 of file mythsocket.cpp.
|
protectedslot |
Definition at line 263 of file mythsocket.cpp.
Referenced by MythSocket().
| bool MythSocket::Announce | ( | const QStringList & | new_announce | ) |
Definition at line 460 of file mythsocket.cpp.
Referenced by ControlRequestHandler::AnnounceSocket().
|
signal |
Referenced by MythSocket(), and ReadyReadHandler().
|
protectedslot |
Definition at line 277 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 179 of file mythsocket.cpp.
Referenced by MythSocket().
| bool MythSocket::ConnectToHost | ( | const QHostAddress & | address, |
| quint16 | port | ||
| ) |
Definition at line 291 of file mythsocket.cpp.
| bool MythSocket::ConnectToHost | ( | const QString & | host, |
| quint16 | port | ||
| ) |
connect to host
Definition at line 378 of file mythsocket.cpp.
Referenced by MythCoreContext::ConnectCommandSocket(), ConnectToHost(), ZMClient::connectToHost(), and OutboundRequestHandler::DoConnectToMaster().
|
protectedslot |
Definition at line 605 of file mythsocket.cpp.
| void MythSocket::DisconnectFromHost | ( | void | ) |
Definition at line 502 of file mythsocket.cpp.
Referenced by MythSocketManager::HandleDone(), MainServer::HandleDone(), ZMClient::readData(), MythCoreContext::ResetSockets(), ZMClient::shutdown(), and ~MythSocket().
|
protectedslot |
Definition at line 688 of file mythsocket.cpp.
|
protectedslot |
Definition at line 245 of file mythsocket.cpp.
Referenced by MythSocket().
|
protectedslot |
Definition at line 230 of file mythsocket.cpp.
Referenced by MythSocket().
|
inline |
Definition at line 44 of file mythsocket.h.
| QHostAddress MythSocket::GetPeerAddress | ( | void | ) | const |
Definition at line 585 of file mythsocket.cpp.
Referenced by MainServer::HandleAnnounce().
| int MythSocket::GetPeerPort | ( | void | ) | const |
Definition at line 591 of file mythsocket.cpp.
| int MythSocket::GetSocketDescriptor | ( | void | ) | const |
Definition at line 579 of file mythsocket.cpp.
Referenced by FileServerHandler::HandleAnnounce(), MainServer::HandleAnnounce(), and MainServer::ProcessRequest().
|
inline |
Definition at line 46 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
| bool MythSocket::IsConnected | ( | void | ) | const |
Definition at line 555 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 561 of file mythsocket.cpp.
Referenced by CallReadyReadHandler(), MainServer::ProcessRequest(), MythSocketManager::ProcessRequest(), RemoteFile::Read(), PlaybackSock::ReadStringList(), MythCoreContext::readyRead(), and RemoteFile::Write().
|
protectedslot |
Definition at line 599 of file mythsocket.cpp.
|
inline |
Definition at line 41 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
|
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().
| int MythSocket::Read | ( | char * | data, |
| int | size, | ||
| std::chrono::milliseconds | max_wait | ||
| ) |
Definition at line 531 of file mythsocket.cpp.
Referenced by RemoteFile::Read(), ZMClient::readData(), FileTransfer::WriteBlock(), and BEFileTransfer::WriteBlock().
|
protectedslot |
Definition at line 960 of file mythsocket.cpp.
| bool MythSocket::ReadStringList | ( | QStringList & | list, |
| std::chrono::milliseconds | timeoutMS = kShortTimeout |
||
| ) |
Definition at line 317 of file mythsocket.cpp.
Referenced by Announce(), MythCoreContext::CheckProtoVersion(), MainServer::ProcessRequestWork(), MythSocketManager::ProcessRequestWork(), RemoteFile::Read(), PlaybackSock::ReadStringList(), MythCoreContext::readyRead(), SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), RemoteEncoder::SendReceiveStringList(), PlaybackSock::SendReceiveStringList(), MythCoreContext::SetupCommandSocket(), Validate(), and RemoteFile::Write().
|
protectedslot |
Definition at line 794 of file mythsocket.cpp.
|
protectedslot |
Definition at line 268 of file mythsocket.cpp.
Referenced by MythSocket().
| void MythSocket::Reset | ( | void | ) |
Definition at line 545 of file mythsocket.cpp.
Referenced by RemoteFile::Read(), RemoteFile::Reset(), and RemoteFile::SeekInternal().
|
protectedslot |
Definition at line 983 of file mythsocket.cpp.
Referenced by ReadStringListReal().
| bool MythSocket::SendReceiveStringList | ( | QStringList & | list, |
| uint | min_reply_length = 0, |
||
| std::chrono::milliseconds | timeoutMS = kLongTimeout |
||
| ) |
Definition at line 330 of file mythsocket.cpp.
Referenced by MythCoreContext::AllowShutdown(), MythCoreContext::BlockShutdown(), RemoteFile::Close(), FileSystemInfoManager::GetInfoList(), RemoteFile::GetRealFileSize(), StorageGroup::remoteGetFileList(), RemoteSendReceiveStringList(), RemoteFile::ReOpen(), RemoteFile::SeekInternal(), ZMClient::sendReceiveStringList(), MythCoreContext::SendReceiveStringList(), SocketHandler::SendReceiveStringList(), PlaybackSock::SendReceiveStringList(), and RemoteFile::SetTimeout().
| void MythSocket::SetAnnounce | ( | const QStringList & | new_announce | ) |
Definition at line 496 of file mythsocket.cpp.
Referenced by BaseRequestHandler::HandleAnnounce().
|
inline |
Definition at line 48 of file mythsocket.h.
Referenced by BEFileTransfer::BEFileTransfer(), FileTransfer::FileTransfer(), and PlaybackSock::SendReceiveStringList().
| bool MythSocket::Validate | ( | std::chrono::milliseconds | timeout = kMythSocketLongTimeout, |
| bool | error_dialog_desired = false |
||
| ) |
Definition at line 407 of file mythsocket.cpp.
Referenced by OutboundRequestHandler::DoConnectToMaster().
| int MythSocket::Write | ( | const char * | data, |
| int | size | ||
| ) |
Definition at line 518 of file mythsocket.cpp.
Referenced by FileTransfer::RequestBlock(), BEFileTransfer::RequestBlock(), and RemoteFile::Write().
|
protectedslot |
Definition at line 955 of file mythsocket.cpp.
| bool MythSocket::WriteStringList | ( | const QStringList & | list | ) |
Definition at line 305 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().
|
protectedslot |
Definition at line 693 of file mythsocket.cpp.
|
friend |
Definition at line 29 of file mythsocket.h.
|
staticconstexpr |
Definition at line 71 of file mythsocket.h.
Referenced by MythCoreContext::SendReceiveStringList().
|
staticconstexpr |
Definition at line 70 of file mythsocket.h.
Referenced by Announce(), RemoteFile::Close(), MythCoreContext::ConnectCommandSocket(), RemoteFile::Read(), MythCoreContext::SendReceiveStringList(), RemoteEncoder::SendReceiveStringList(), MythCoreContext::SetupCommandSocket(), and RemoteFile::Write().
|
staticprotected |
Definition at line 123 of file mythsocket.h.
Referenced by ConnectHandler().
|
protected |
Definition at line 121 of file mythsocket.h.
Referenced by Announce(), and SetAnnounce().
|
protected |
Definition at line 112 of file mythsocket.h.
Referenced by CallReadyReadHandler(), ConnectHandler(), DisconnectHandler(), ErrorHandler(), ReadyReadHandler(), SendReceiveStringList(), and ~MythSocket().
|
protected |
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().
|
protected |
Definition at line 114 of file mythsocket.h.
Referenced by ReadyReadHandler(), and SendReceiveStringList().
|
protected |
Definition at line 120 of file mythsocket.h.
Referenced by Announce(), and SetAnnounce().
|
protected |
Definition at line 119 of file mythsocket.h.
Referenced by Announce(), MythSocketManager::HandleVersion(), and Validate().
|
mutableprotected |
Definition at line 108 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), GetPeerAddress(), GetPeerPort(), GetSocketDescriptor(), and IsConnected().
|
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 109 of file mythsocket.h.
Referenced by ConnectHandler(), DisconnectHandler(), and GetSocketDescriptor().
|
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().
|
protected |
Definition at line 113 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().
|
staticprotected |
Definition at line 126 of file mythsocket.h.
Referenced by ConnectToHostReal().
|
staticprotected |
Definition at line 125 of file mythsocket.h.
Referenced by ConnectToHostReal().
|
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().
|
staticprotected |
Definition at line 128 of file mythsocket.h.
Referenced by MythSocket(), and ~MythSocket().