MythSocket Class Reference

#include <mythsocket.h>

List of all members.


Detailed Description

Definition at line 24 of file mythsocket.h.


Public Types

enum  State { Connected, Connecting, HostLookup, Idle }

Public Member Functions

 MythSocket (int socket=-1, MythSocketCBs *cb=NULL)
void close (void)
void deleteLater (void)
void UpRef (void)
bool DownRef (void)
State state (void)
QString stateToString (void)
QString stateToString (const State state)
QString errorToString (void)
QString errorToString (const Error error)
void setSocket (int socket, Type type=QSocketDevice::Stream)
void setCallbacks (MythSocketCBs *cb)
Q_LONG readBlock (char *data, Q_ULONG len)
Q_LONG writeBlock (const char *data, Q_ULONG len)
 Attempt to write 'len' bytes to socket.
bool readStringList (QStringList &list, bool quickTimeout=false)
bool writeStringList (QStringList &list)
bool writeData (const char *data, Q_ULONG len)
 Write len bytes to data to socket.
bool connect (const QHostAddress &addr, Q_UINT16 port)
 connect to host
bool connect (const QString &host, Q_UINT16 port)
 connect to host
void Lock ()
void Unlock ()

Protected Member Functions

 ~MythSocket ()
void setState (const State state)

Static Protected Member Functions

static void StartReadyReadThread (void)
static void * readyReadThread (void *)
static void AddToReadyRead (MythSocket *sock)
static void RemoveFromReadyRead (MythSocket *sock)
static void WakeReadyReadThread (void)
static void ShutdownReadyReadThread (void)

Protected Attributes

MythSocketCBsm_cb
State m_state
QHostAddress m_addr
Q_UINT16 m_port
int m_ref_count
bool m_notifyread
QMutex m_ref_lock
QMutex m_lock

Static Protected Attributes

static const uint kSocketBufferSize = 128000
static pthread_t m_readyread_thread = (pthread_t)0
static bool m_readyread_run = false
static QMutex m_readyread_lock
static QPtrList< MythSocketm_readyread_list
static QPtrList< MythSocketm_readyread_dellist
static QPtrList< MythSocketm_readyread_addlist
static int m_readyread_pipe [2] = {-1, -1}

Friends

class QPtrList< MythSocket >
void readyReadThread_iffound (MythSocket *)

Member Enumeration Documentation

Enumerator:
Connected 
Connecting 
HostLookup 
Idle 

Definition at line 31 of file mythsocket.h.


Constructor & Destructor Documentation

MythSocket::MythSocket ( int  socket = -1,
MythSocketCBs cb = NULL 
)

Definition at line 40 of file mythsocket.cpp.

MythSocket::~MythSocket (  )  [protected]

Definition at line 53 of file mythsocket.cpp.


Member Function Documentation

void MythSocket::close ( void   ) 

void MythSocket::deleteLater ( void   ) 

void MythSocket::UpRef ( void   ) 

bool MythSocket::DownRef ( void   ) 

MythSocket::State MythSocket::state ( void   ) 

QString MythSocket::stateToString ( void   )  [inline]

Definition at line 45 of file mythsocket.h.

Referenced by setState().

QString MythSocket::stateToString ( const State  state  ) 

Definition at line 123 of file mythsocket.cpp.

QString MythSocket::errorToString ( void   )  [inline]

QString MythSocket::errorToString ( const Error  error  ) 

Definition at line 140 of file mythsocket.cpp.

void MythSocket::setSocket ( int  socket,
Type  type = QSocketDevice::Stream 
)

Definition at line 169 of file mythsocket.cpp.

Referenced by MythSocket().

void MythSocket::setCallbacks ( MythSocketCBs cb  ) 

Q_LONG MythSocket::readBlock ( char *  data,
Q_ULONG  len 
)

Q_LONG MythSocket::writeBlock ( const char *  data,
Q_ULONG  len 
)

Attempt to write 'len' bytes to socket.

Returns:
actual bytes written

Definition at line 225 of file mythsocket.cpp.

Referenced by writeData(), and writeStringList().

bool MythSocket::readStringList ( QStringList &  list,
bool  quickTimeout = false 
)

bool MythSocket::writeStringList ( QStringList &  list  ) 

bool MythSocket::writeData ( const char *  data,
Q_ULONG  len 
)

Write len bytes to data to socket.

Returns:
true if entire len of data is written

Definition at line 341 of file mythsocket.cpp.

Referenced by FileTransfer::RequestBlock().

bool MythSocket::connect ( const QHostAddress &  addr,
Q_UINT16  port 
)

bool MythSocket::connect ( const QString &  host,
Q_UINT16  port 
)

connect to host

Returns:
true on success

Definition at line 594 of file mythsocket.cpp.

void MythSocket::Lock ( void   ) 

void MythSocket::Unlock ( void   ) 

void MythSocket::setState ( const State  state  )  [protected]

Definition at line 112 of file mythsocket.cpp.

Referenced by close(), connect(), and setSocket().

void MythSocket::StartReadyReadThread ( void   )  [static, protected]

Definition at line 662 of file mythsocket.cpp.

Referenced by AddToReadyRead().

void * MythSocket::readyReadThread ( void *   )  [static, protected]

Definition at line 747 of file mythsocket.cpp.

Referenced by StartReadyReadThread().

void MythSocket::AddToReadyRead ( MythSocket sock  )  [static, protected]

Definition at line 686 of file mythsocket.cpp.

Referenced by MythSocket(), and setCallbacks().

void MythSocket::RemoveFromReadyRead ( MythSocket sock  )  [static, protected]

Definition at line 703 of file mythsocket.cpp.

Referenced by DownRef(), and setCallbacks().

void MythSocket::WakeReadyReadThread ( void   )  [static, protected]

void MythSocket::ShutdownReadyReadThread ( void   )  [static, protected]

Definition at line 645 of file mythsocket.cpp.

Referenced by StartReadyReadThread().


Friends And Related Function Documentation

friend class QPtrList< MythSocket > [friend]

Definition at line 101 of file mythsocket.h.

void readyReadThread_iffound ( MythSocket sock  )  [friend]

Definition at line 725 of file mythsocket.cpp.

Referenced by readyReadThread().


Member Data Documentation

Definition at line 73 of file mythsocket.h.

Referenced by setState(), and state().

QHostAddress MythSocket::m_addr [protected]

Definition at line 74 of file mythsocket.h.

Q_UINT16 MythSocket::m_port [protected]

Definition at line 75 of file mythsocket.h.

int MythSocket::m_ref_count [protected]

Definition at line 76 of file mythsocket.h.

Referenced by DownRef(), and UpRef().

Definition at line 78 of file mythsocket.h.

Referenced by readBlock(), readStringList(), readyReadThread(), and readyReadThread_iffound().

const uint MythSocket::kSocketBufferSize = 128000 [static, protected]

Definition at line 80 of file mythsocket.h.

Referenced by connect(), and writeData().

QMutex MythSocket::m_ref_lock [protected]

Definition at line 82 of file mythsocket.h.

Referenced by DownRef(), and UpRef().

QMutex MythSocket::m_lock [protected]

Definition at line 83 of file mythsocket.h.

Referenced by Lock(), readyReadThread(), and Unlock().

Definition at line 85 of file mythsocket.h.

Referenced by ShutdownReadyReadThread(), and StartReadyReadThread().

bool MythSocket::m_readyread_run = false [static, protected]

Definition at line 86 of file mythsocket.h.

Referenced by readyReadThread(), ShutdownReadyReadThread(), and StartReadyReadThread().

QMutex MythSocket::m_readyread_lock [static, protected]

QPtrList< MythSocket > MythSocket::m_readyread_list [static, protected]

Definition at line 88 of file mythsocket.h.

Referenced by readyReadThread().

QPtrList< MythSocket > MythSocket::m_readyread_dellist [static, protected]

Definition at line 89 of file mythsocket.h.

Referenced by readyReadThread(), and RemoveFromReadyRead().

QPtrList< MythSocket > MythSocket::m_readyread_addlist [static, protected]

Definition at line 90 of file mythsocket.h.

Referenced by AddToReadyRead(), and readyReadThread().

int MythSocket::m_readyread_pipe = {-1, -1} [static, protected]


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

Generated on Sat Dec 18 05:16:08 2010 for MythTV by  doxygen 1.5.5