MythTV  master
Signals | Public Member Functions | Static Public Attributes | Protected Slots | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
MythSocket Class Reference

Class for communcating between myth backends and frontends. More...

#include <mythsocket.h>

Inheritance diagram for MythSocket:
Inheritance graph
[legend]
Collaboration diagram for MythSocket:
Collaboration graph
[legend]

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 (uint timeout_ms=kMythSocketLongTimeout, bool error_dialog_desired=false)
 
bool IsValidated (void) const
 
bool Announce (const QStringList &strlist)
 
QStringList GetAnnounce (void) const
 
void SetAnnounce (const QStringList &strlist)
 
bool IsAnnounced (void) const
 
void SetReadyReadCallbackEnabled (bool enabled)
 
bool SendReceiveStringList (QStringList &list, uint min_reply_length=0, uint timeoutMS=kLongTimeout)
 
bool ReadStringList (QStringList &list, uint timeoutMS=kShortTimeout)
 
bool WriteStringList (const QStringList &list)
 
bool IsConnected (void) const
 
bool IsDataAvailable (void) const
 
QHostAddress GetPeerAddress (void) const
 
int GetPeerPort (void) const
 
int GetSocketDescriptor (void) const
 
int Write (const char *, int size)
 
int Read (char *, int size, int max_wait_ms)
 
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 const uint kShortTimeout = kMythSocketShortTimeout
 
static const uint kLongTimeout = kMythSocketLongTimeout
 

Protected Slots

void ConnectHandler (void)
 
void ErrorHandler (QAbstractSocket::SocketError)
 
void AboutToCloseHandler (void)
 
void DisconnectHandler (void)
 
void ReadyReadHandler (void)
 
void CallReadyReadHandler (void)
 
void ReadStringListReal (QStringList *list, uint timeoutMS, bool *ret)
 
void WriteStringListReal (const QStringList *list, bool *ret)
 
void ConnectToHostReal (QHostAddress address, quint16 port, bool *ret)
 
void DisconnectFromHostReal (void)
 
void WriteReal (const char *, int size, int *ret)
 
void ReadReal (char *, int size, int max_wait_ms, int *ret)
 
void ResetReal (void)
 
void IsDataAvailableReal (bool *ret) const
 

Protected Member Functions

 ~MythSocket ()
 
- 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
 
MThreadm_thread
 
QMutex m_lock
 
qt_socket_fd_t m_socketDescriptor
 
QHostAddress m_peerAddress
 
int m_peerPort
 
MythSocketCBsm_callback
 
bool m_useSharedThread
 
QAtomicInt m_disableReadyReadCallback
 
bool m_connected
 
QAtomicInt m_dataAvailable
 This is used internally as a hint that there might be data available for reading. More...
 
bool m_isValidated
 
bool m_isAnnounced
 
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
 

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 MThreads_thread = nullptr
 
static int s_thread_cnt = 0
 

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...
 

Detailed Description

Class for communcating between myth backends and frontends.

Note
Access to the methods of MythSocket must be externally serialized (i.e. the MythSocket must only be available to one thread at a time).

Definition at line 26 of file mythsocket.h.

Constructor & Destructor Documentation

◆ MythSocket()

MythSocket::MythSocket ( qt_socket_fd_t  socket = -1,
MythSocketCBs cb = nullptr,
bool  use_shared_thread = false 
)

Definition at line 81 of file mythsocket.cpp.

◆ ~MythSocket()

MythSocket::~MythSocket ( )
protected

Definition at line 159 of file mythsocket.cpp.

Member Function Documentation

◆ ConnectToHost() [1/2]

bool MythSocket::ConnectToHost ( const QString &  host,
quint16  port 
)

◆ ConnectToHost() [2/2]

bool MythSocket::ConnectToHost ( const QHostAddress &  address,
quint16  port 
)

Definition at line 306 of file mythsocket.cpp.

◆ DisconnectFromHost()

void MythSocket::DisconnectFromHost ( void  )

◆ Validate()

bool MythSocket::Validate ( uint  timeout_ms = kMythSocketLongTimeout,
bool  error_dialog_desired = false 
)

Definition at line 422 of file mythsocket.cpp.

Referenced by OutboundRequestHandler::DoConnectToMaster().

◆ IsValidated()

bool MythSocket::IsValidated ( void  ) const
inline

Definition at line 42 of file mythsocket.h.

Referenced by MythSocketManager::ProcessRequestWork().

◆ Announce()

bool MythSocket::Announce ( const QStringList &  strlist)

Definition at line 475 of file mythsocket.cpp.

Referenced by ControlRequestHandler::AnnounceSocket().

◆ GetAnnounce()

QStringList MythSocket::GetAnnounce ( void  ) const
inline

Definition at line 45 of file mythsocket.h.

◆ SetAnnounce()

void MythSocket::SetAnnounce ( const QStringList &  strlist)

Definition at line 511 of file mythsocket.cpp.

Referenced by BaseRequestHandler::HandleAnnounce().

◆ IsAnnounced()

bool MythSocket::IsAnnounced ( void  ) const
inline

Definition at line 47 of file mythsocket.h.

Referenced by MythSocketManager::ProcessRequestWork().

◆ SetReadyReadCallbackEnabled()

void MythSocket::SetReadyReadCallbackEnabled ( bool  enabled)
inline

◆ SendReceiveStringList()

bool MythSocket::SendReceiveStringList ( QStringList &  list,
uint  min_reply_length = 0,
uint  timeoutMS = kLongTimeout 
)

◆ ReadStringList()

bool MythSocket::ReadStringList ( QStringList &  list,
uint  timeoutMS = kShortTimeout 
)

◆ WriteStringList()

bool MythSocket::WriteStringList ( const QStringList &  list)

◆ IsConnected()

bool MythSocket::IsConnected ( void  ) const

◆ IsDataAvailable()

bool MythSocket::IsDataAvailable ( void  ) const

◆ GetPeerAddress()

QHostAddress MythSocket::GetPeerAddress ( void  ) const

Definition at line 600 of file mythsocket.cpp.

Referenced by MainServer::HandleAnnounce().

◆ GetPeerPort()

int MythSocket::GetPeerPort ( void  ) const

Definition at line 606 of file mythsocket.cpp.

◆ GetSocketDescriptor()

int MythSocket::GetSocketDescriptor ( void  ) const

◆ Write()

int MythSocket::Write ( const char *  data,
int  size 
)

Definition at line 533 of file mythsocket.cpp.

Referenced by FileTransfer::RequestBlock(), and RemoteFile::Write().

◆ Read()

int MythSocket::Read ( char *  data,
int  size,
int  max_wait_ms 
)

Definition at line 546 of file mythsocket.cpp.

Referenced by RemoteFile::Read(), ZMClient::readData(), and FileTransfer::WriteBlock().

◆ Reset()

void MythSocket::Reset ( void  )

Definition at line 560 of file mythsocket.cpp.

Referenced by RemoteFile::Read(), RemoteFile::Reset(), and RemoteFile::SeekInternal().

◆ CallReadyRead

void MythSocket::CallReadyRead ( void  )
signal

Referenced by MythSocket(), and ReadyReadHandler().

◆ ConnectHandler

void MythSocket::ConnectHandler ( void  )
protectedslot

Definition at line 194 of file mythsocket.cpp.

Referenced by MythSocket().

◆ ErrorHandler

void MythSocket::ErrorHandler ( QAbstractSocket::SocketError  err)
protectedslot

Definition at line 245 of file mythsocket.cpp.

Referenced by MythSocket().

◆ AboutToCloseHandler

void MythSocket::AboutToCloseHandler ( void  )
protectedslot

Definition at line 278 of file mythsocket.cpp.

Referenced by MythSocket().

◆ DisconnectHandler

void MythSocket::DisconnectHandler ( void  )
protectedslot

Definition at line 260 of file mythsocket.cpp.

Referenced by MythSocket().

◆ ReadyReadHandler

void MythSocket::ReadyReadHandler ( void  )
protectedslot

Definition at line 283 of file mythsocket.cpp.

Referenced by MythSocket().

◆ CallReadyReadHandler

void MythSocket::CallReadyReadHandler ( void  )
protectedslot

Definition at line 292 of file mythsocket.cpp.

Referenced by MythSocket().

◆ ReadStringListReal

void MythSocket::ReadStringListReal ( QStringList *  list,
uint  timeoutMS,
bool ret 
)
protectedslot

Definition at line 810 of file mythsocket.cpp.

◆ WriteStringListReal

void MythSocket::WriteStringListReal ( const QStringList *  list,
bool ret 
)
protectedslot

Definition at line 708 of file mythsocket.cpp.

◆ ConnectToHostReal

void MythSocket::ConnectToHostReal ( QHostAddress  address,
quint16  port,
bool ret 
)
protectedslot

Definition at line 620 of file mythsocket.cpp.

◆ DisconnectFromHostReal

void MythSocket::DisconnectFromHostReal ( void  )
protectedslot

Definition at line 703 of file mythsocket.cpp.

◆ WriteReal

void MythSocket::WriteReal ( const char *  data,
int  size,
int *  ret 
)
protectedslot

Definition at line 969 of file mythsocket.cpp.

◆ ReadReal

void MythSocket::ReadReal ( char *  data,
int  size,
int  max_wait_ms,
int *  ret 
)
protectedslot

Definition at line 974 of file mythsocket.cpp.

◆ ResetReal

void MythSocket::ResetReal ( void  )
protectedslot

Definition at line 997 of file mythsocket.cpp.

Referenced by ReadStringListReal().

◆ IsDataAvailableReal

void MythSocket::IsDataAvailableReal ( bool ret) const
protectedslot

Definition at line 614 of file mythsocket.cpp.

Friends And Related Function Documentation

◆ MythSocketManager

friend class MythSocketManager
friend

Definition at line 30 of file mythsocket.h.

Member Data Documentation

◆ kShortTimeout

const uint MythSocket::kShortTimeout = kMythSocketShortTimeout
static

◆ kLongTimeout

const uint MythSocket::kLongTimeout = kMythSocketLongTimeout
static

Definition at line 72 of file mythsocket.h.

Referenced by MythCoreContext::SendReceiveStringList().

◆ m_tcpSocket

QTcpSocket* MythSocket::m_tcpSocket
protected

◆ m_thread

MThread* MythSocket::m_thread
protected

◆ m_lock

QMutex MythSocket::m_lock
mutableprotected

◆ m_socketDescriptor

qt_socket_fd_t MythSocket::m_socketDescriptor
protected

Definition at line 102 of file mythsocket.h.

Referenced by ConnectHandler(), DisconnectHandler(), and GetSocketDescriptor().

◆ m_peerAddress

QHostAddress MythSocket::m_peerAddress
protected

Definition at line 103 of file mythsocket.h.

Referenced by ConnectHandler(), DisconnectHandler(), and GetPeerAddress().

◆ m_peerPort

int MythSocket::m_peerPort
protected

Definition at line 104 of file mythsocket.h.

Referenced by ConnectHandler(), DisconnectHandler(), and GetPeerPort().

◆ m_callback

MythSocketCBs* MythSocket::m_callback
protected

◆ m_useSharedThread

bool MythSocket::m_useSharedThread
protected

Definition at line 106 of file mythsocket.h.

Referenced by MythSocket(), and ~MythSocket().

◆ m_disableReadyReadCallback

QAtomicInt MythSocket::m_disableReadyReadCallback
protected

Definition at line 107 of file mythsocket.h.

Referenced by ReadyReadHandler(), and SendReceiveStringList().

◆ m_connected

bool MythSocket::m_connected
protected

Definition at line 108 of file mythsocket.h.

Referenced by ConnectHandler(), DisconnectHandler(), IsConnected(), and MythSocket().

◆ m_dataAvailable

QAtomicInt MythSocket::m_dataAvailable
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().

◆ m_isValidated

bool MythSocket::m_isValidated
protected

Definition at line 112 of file mythsocket.h.

Referenced by Announce(), MythSocketManager::HandleVersion(), and Validate().

◆ m_isAnnounced

bool MythSocket::m_isAnnounced
protected

Definition at line 113 of file mythsocket.h.

Referenced by Announce(), and SetAnnounce().

◆ m_announce

QStringList MythSocket::m_announce
protected

Definition at line 114 of file mythsocket.h.

Referenced by Announce(), and SetAnnounce().

◆ kSocketReceiveBufferSize

const int MythSocket::kSocketReceiveBufferSize = 128 * 1024
staticprotected

Definition at line 116 of file mythsocket.h.

Referenced by ConnectHandler().

◆ s_loopbackCacheLock

QMutex MythSocket::s_loopbackCacheLock
staticprotected

Definition at line 118 of file mythsocket.h.

Referenced by ConnectToHostReal().

◆ s_loopbackCache

QHash< QString, QHostAddress::SpecialAddress > MythSocket::s_loopbackCache
staticprotected

Definition at line 119 of file mythsocket.h.

Referenced by ConnectToHostReal().

◆ s_thread_lock

QMutex MythSocket::s_thread_lock
staticprotected

Definition at line 121 of file mythsocket.h.

Referenced by MythSocket(), and ~MythSocket().

◆ s_thread

MThread * MythSocket::s_thread = nullptr
staticprotected

Definition at line 122 of file mythsocket.h.

Referenced by MythSocket(), and ~MythSocket().

◆ s_thread_cnt

int MythSocket::s_thread_cnt = 0
staticprotected

Definition at line 123 of file mythsocket.h.

Referenced by MythSocket(), and ~MythSocket().


The documentation for this class was generated from the following files: