|
MythTV
0.26-pre
|
#include <mythsocket.h>
Public Types | |
| enum | State { Connected, Connecting, HostLookup, Idle } |
Public Member Functions | |
| MythSocket (int socket=-1, MythSocketCBs *cb=NULL) | |
| void | close (void) |
| bool | closedByRemote (void) |
| void | deleteLater (void) |
| void | UpRef (void) |
| bool | DownRef (void) |
| State | state (void) const |
| QString | stateToString (void) const |
| QString | stateToString (const State state) const |
| QString | errorToString (void) const |
| QString | errorToString (const Error error) const |
| bool | Validate (uint timeout_ms=kMythSocketLongTimeout, bool error_dialog_desired=false) |
| void | setValidated (bool isValidated=true) |
| bool | isValidated (void) |
| bool | Announce (QStringList &strlist) |
| QStringList | getAnnounce (void) |
| void | setAnnounce (QStringList &strlist) |
| bool | isAnnounced (void) |
| bool | isExpectingReply (void) |
| void | setSocket (int socket, Type type=MSocketDevice::Stream) |
| void | setCallbacks (MythSocketCBs *cb) |
| void | useReadyReadCallback (bool useReadyReadCallback=true) |
| qint64 | readBlock (char *data, quint64 len) |
| qint64 | writeBlock (const char *data, quint64 len) |
| Attempt to write 'len' bytes to socket. | |
| bool | readStringList (QStringList &list, uint timeoutMS=kLongTimeout) |
| bool | readStringList (QStringList &list, bool quickTimeout) |
| bool | writeStringList (QStringList &list) |
| bool | SendReceiveStringList (QStringList &list, uint min_reply_length=0) |
| bool | readData (char *data, quint64 len) |
| Read len bytes to data from socket. | |
| bool | writeData (const char *data, quint64 len) |
| Write len bytes to data to socket. | |
| bool | connect (const QHostAddress &hadr, quint16 port) |
| connect to host | |
| bool | connect (const QString &host, quint16 port) |
| connect to host | |
| void | Lock (void) const |
| bool | TryLock (bool wakereadyread) const |
| void | Unlock (bool wakereadyread=true) const |
Static Public Attributes | |
| static const uint | kShortTimeout = kMythSocketShortTimeout |
| static const uint | kLongTimeout = kMythSocketLongTimeout |
Protected Member Functions | |
| ~MythSocket () | |
| void | setState (const State state) |
Protected Attributes | |
| MythSocketCBs * | m_cb |
| bool | m_useReadyReadCallback |
| State | m_state |
| QHostAddress | m_addr |
| quint16 | m_port |
| int | m_ref_count |
| bool | m_notifyread |
| QMutex | m_ref_lock |
| QMutex | m_lock |
| bool | m_expectingreply |
| bool | m_isValidated |
| bool | m_isAnnounced |
| QStringList | m_announce |
Static Protected Attributes | |
| static const uint | kSocketBufferSize = 128000 |
| static QMutex | s_readyread_thread_lock |
| static MythSocketThread * | s_readyread_thread = NULL |
| static QMap< QString, QHostAddress::SpecialAddress > | s_loopback_cache |
Friends | |
| class | MythSocketThread |
| class | QList< MythSocket * > |
| void | ShutdownRRT (void) |
Definition at line 18 of file mythsocket.h.
| enum MythSocket::State |
Definition at line 27 of file mythsocket.h.
| MythSocket::MythSocket | ( | int | socket = -1, |
| MythSocketCBs * | cb = NULL |
||
| ) |
Definition at line 44 of file mythsocket.cpp.
| MythSocket::~MythSocket | ( | ) | [protected] |
Definition at line 73 of file mythsocket.cpp.
Closes the socket and sets the socket identifier to -1 (invalid).
(This function ignores errors; if there are any then a file descriptor leakage might result. As far as we know, the only error that can arise is EBADF, and that would of course not cause leakage. There may be OS-specific errors that we haven't come across, however.)
Reimplemented from MSocketDevice.
Definition at line 210 of file mythsocket.cpp.
Referenced by connect(), MythSocketManager::HandleDone(), MainServer::HandleDone(), readBlock(), ZMClient::readData(), readData(), readStringList(), MythSocketThread::ReadyToBeRead(), setSocket(), ZMClient::shutdown(), LCD::shutdown(), writeBlock(), writeData(), and ~MythSocket().
Definition at line 221 of file mythsocket.cpp.
Referenced by MythSocketThread::ReadyToBeRead().
Definition at line 95 of file mythsocket.cpp.
Referenced by MythSocketThread::AddToReadyRead(), and SocketHandler::SocketHandler().
Definition at line 102 of file mythsocket.cpp.
Referenced by RemoteFile::Close(), connect_to_master(), MythCoreContext::ConnectCommandSocket(), MythCoreContext::ConnectEventSocket(), MainServer::connectionClosed(), MythCoreContext::connectionClosed(), ZMClient::connectToHost(), LCD::connectToHost(), MythCoreContext::ConnectToMasterServer(), OutboundRequestHandler::DoConnectToMaster(), RemoteFile::openSocket(), MainServer::reconnectTimeout(), RemoteGetFileList(), RemoteEncoder::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), telnet(), LCD::~LCD(), MythCoreContextPrivate::~MythCoreContextPrivate(), RemoteEncoder::~RemoteEncoder(), RemoteFile::~RemoteFile(), SocketHandler::~SocketHandler(), and ZMClient::~ZMClient().
| MythSocket::State MythSocket::state | ( | void | ) | const |
Definition at line 126 of file mythsocket.cpp.
Referenced by MythCoreContext::AllowShutdown(), MythCoreContext::BlockShutdown(), connect(), MythCoreContext::ConnectEventSocket(), OutboundRequestHandler::DoConnectToMaster(), readBlock(), readData(), readStringList(), MythCoreContext::readyRead(), MainServer::reconnectTimeout(), LCD::sendToServer(), setSocket(), setState(), writeBlock(), writeData(), and writeStringList().
| QString MythSocket::stateToString | ( | void | ) | const [inline] |
Definition at line 42 of file mythsocket.h.
Referenced by setState(), and stateToString().
| QString MythSocket::stateToString | ( | const State | state | ) | const |
Definition at line 142 of file mythsocket.cpp.
| QString MythSocket::errorToString | ( | void | ) | const [inline] |
Definition at line 45 of file mythsocket.h.
Referenced by connect(), LCD::connectionFailed(), errorToString(), ZMClient::readData(), readData(), readStringList(), writeData(), and writeStringList().
| QString MythSocket::errorToString | ( | const Error | error | ) | const |
Definition at line 159 of file mythsocket.cpp.
| bool MythSocket::Validate | ( | uint | timeout_ms = kMythSocketLongTimeout, |
| bool | error_dialog_desired = false |
||
| ) |
Definition at line 860 of file mythsocket.cpp.
Referenced by OutboundRequestHandler::DoConnectToMaster().
| void MythSocket::setValidated | ( | bool | isValidated = true | ) | [inline] |
Definition at line 50 of file mythsocket.h.
Referenced by MythSocketManager::HandleVersion(), and Validate().
| bool MythSocket::isValidated | ( | void | ) | [inline] |
Definition at line 51 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
| bool MythSocket::Announce | ( | QStringList & | strlist | ) |
Definition at line 910 of file mythsocket.cpp.
| QStringList MythSocket::getAnnounce | ( | void | ) | [inline] |
Definition at line 54 of file mythsocket.h.
| void MythSocket::setAnnounce | ( | QStringList & | strlist | ) |
Definition at line 942 of file mythsocket.cpp.
Referenced by BaseRequestHandler::HandleAnnounce().
| bool MythSocket::isAnnounced | ( | void | ) | [inline] |
Definition at line 56 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequestWork().
| bool MythSocket::isExpectingReply | ( | void | ) | [inline] |
Definition at line 58 of file mythsocket.h.
Referenced by MythSocketManager::ProcessRequest(), and MythSocketManager::readyRead().
| void MythSocket::setSocket | ( | int | socket, |
| Type | type = MSocketDevice::Stream |
||
| ) | [virtual] |
Sets the socket device to operate on the existing socket socket.
The type argument must match the actual socket type; use MSocketDevice::Stream for a reliable, connection-oriented TCP socket, or MSocketDevice::Datagram for an unreliable, connectionless UDP socket.
Any existing socket is closed.
Reimplemented from MSocketDevice.
Definition at line 188 of file mythsocket.cpp.
Referenced by MythSocket().
Definition at line 79 of file mythsocket.cpp.
Referenced by MythCoreContext::ConnectEventSocket(), MythSocketManager::newConnection(), MainServer::newConnection(), and MainServer::reconnectTimeout().
| void MythSocket::useReadyReadCallback | ( | bool | useReadyReadCallback = true | ) | [inline] |
Definition at line 62 of file mythsocket.h.
Referenced by FileTransfer::FileTransfer(), and useReadyReadCallback().
| qint64 MythSocket::readBlock | ( | char * | data, |
| quint64 | maxlen | ||
| ) |
Reads maxlen bytes from the socket into data and returns the number of bytes read. Returns -1 if an error occurred. Returning 0 is not an error. For Stream sockets, 0 is returned when the remote host closes the connection. For Datagram sockets, 0 is a valid datagram size.
Reimplemented from MSocketDevice.
Definition at line 239 of file mythsocket.cpp.
Referenced by RemoteFile::Read(), ZMClient::readData(), readData(), readStringList(), LCD::readyRead(), and RemoteFile::Reset().
| qint64 MythSocket::writeBlock | ( | const char * | data, |
| quint64 | len | ||
| ) |
Attempt to write 'len' bytes to socket.
Reimplemented from MSocketDevice.
Definition at line 264 of file mythsocket.cpp.
Referenced by RemoteFile::Write(), writeData(), and writeStringList().
| bool MythSocket::readStringList | ( | QStringList & | list, |
| uint | timeoutMS = kLongTimeout |
||
| ) |
Definition at line 513 of file mythsocket.cpp.
Referenced by MythCoreContext::AllowShutdown(), Announce(), MythCoreContext::BlockShutdown(), MythCoreContext::CheckProtoVersion(), RemoteFile::Close(), connect_to_master(), MythCoreContext::ConnectEventSocket(), RemoteFile::openSocket(), MythSocketManager::ProcessRequestWork(), MainServer::ProcessRequestWork(), RemoteFile::Read(), MythCoreContext::readyRead(), MainServer::reconnectTimeout(), RemoteFile::ReOpen(), RemoteFile::Seek(), ZMClient::sendReceiveStringList(), SendReceiveStringList(), RemoteEncoder::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), RemoteFile::SetTimeout(), MythCoreContext::SetupCommandSocket(), Validate(), and RemoteFile::Write().
| bool MythSocket::readStringList | ( | QStringList & | list, |
| bool | quickTimeout | ||
| ) | [inline] |
Definition at line 69 of file mythsocket.h.
| bool MythSocket::writeStringList | ( | QStringList & | list | ) |
Definition at line 299 of file mythsocket.cpp.
Referenced by MythCoreContext::AllowShutdown(), Announce(), MythCoreContext::BlockShutdown(), MythCoreContext::CheckProtoVersion(), RemoteFile::Close(), connect_to_master(), MythCoreContext::ConnectEventSocket(), MainServer::customEvent(), FileServerHandler::HandleAnnounce(), MainServer::HandleAnnounce(), MythSocketManager::HandleVersion(), MainServer::HandleVersion(), RemoteFile::openSocket(), MythSocketManager::ProcessRequestWork(), RemoteFile::Read(), MainServer::reconnectTimeout(), RemoteFile::ReOpen(), RemoteFile::Seek(), ZMClient::sendReceiveStringList(), SendReceiveStringList(), RemoteEncoder::SendReceiveStringList(), MythCoreContext::SendReceiveStringList(), MainServer::SendResponse(), SocketHandler::SendStringList(), RemoteFile::SetTimeout(), MythCoreContext::SetupCommandSocket(), Validate(), and RemoteFile::Write().
| bool MythSocket::SendReceiveStringList | ( | QStringList & | list, |
| uint | min_reply_length = 0 |
||
| ) |
Definition at line 681 of file mythsocket.cpp.
Referenced by RemoteGetFileList(), FileSystemInfo::RemoteGetInfo(), and SocketHandler::SendReceiveStringList().
| bool MythSocket::readData | ( | char * | data, |
| quint64 | len | ||
| ) |
Read len bytes to data from socket.
Definition at line 405 of file mythsocket.cpp.
Referenced by FileTransfer::WriteBlock().
| bool MythSocket::writeData | ( | const char * | data, |
| quint64 | len | ||
| ) |
Write len bytes to data to socket.
Definition at line 461 of file mythsocket.cpp.
Referenced by FileTransfer::RequestBlock().
| bool MythSocket::connect | ( | const QHostAddress & | hadr, |
| quint16 | port | ||
| ) | [virtual] |
connect to host
Reimplemented from MSocketDevice.
Definition at line 789 of file mythsocket.cpp.
Referenced by connect(), connect_to_master(), MythCoreContext::ConnectCommandSocket(), MythCoreContext::ConnectEventSocket(), ZMClient::connectToHost(), LCD::connectToHost(), OutboundRequestHandler::DoConnectToMaster(), RemoteFile::openSocket(), MainServer::reconnectTimeout(), and telnet().
| bool MythSocket::connect | ( | const QString & | host, |
| quint16 | port | ||
| ) |
| void MythSocket::Lock | ( | void | ) | const |
Definition at line 728 of file mythsocket.cpp.
Referenced by MythCoreContext::AllowShutdown(), MythCoreContext::BlockShutdown(), MythCoreContext::ConnectEventSocket(), LCD::connectToHost(), MainServer::customEvent(), OutboundRequestHandler::DoConnectToMaster(), MythSocketManager::ProcessRequest(), MainServer::ProcessRequest(), MainServer::reconnectTimeout(), SendReceiveStringList(), and SocketHandler::SendStringList().
| bool MythSocket::TryLock | ( | bool | wakereadyread | ) | const |
Definition at line 734 of file mythsocket.cpp.
| void MythSocket::Unlock | ( | bool | wakereadyread = true | ) | const |
Definition at line 745 of file mythsocket.cpp.
Referenced by MythCoreContext::AllowShutdown(), MythCoreContext::BlockShutdown(), MythCoreContext::ConnectEventSocket(), LCD::connectToHost(), MainServer::customEvent(), OutboundRequestHandler::DoConnectToMaster(), MythSocketManager::ProcessRequest(), MainServer::ProcessRequest(), MainServer::reconnectTimeout(), SendReceiveStringList(), and SocketHandler::SendStringList().
| void MythSocket::setState | ( | const State | state | ) | [protected] |
Definition at line 131 of file mythsocket.cpp.
Referenced by close(), connect(), and setSocket().
friend class MythSocketThread [friend] |
Definition at line 20 of file mythsocket.h.
Referenced by MythSocket().
friend class QList< MythSocket * > [friend] |
Definition at line 21 of file mythsocket.h.
| void ShutdownRRT | ( | void | ) | [friend] |
Definition at line 47 of file mythsocketthread.cpp.
const uint MythSocket::kShortTimeout = kMythSocketShortTimeout [static] |
Definition at line 86 of file mythsocket.h.
Referenced by MythCoreContext::ConnectCommandSocket(), and RemoteEncoder::SendReceiveStringList().
const uint MythSocket::kLongTimeout = kMythSocketLongTimeout [static] |
Definition at line 87 of file mythsocket.h.
MythSocketCBs* MythSocket::m_cb [protected] |
Definition at line 94 of file mythsocket.h.
Referenced by close(), connect(), DownRef(), MythSocket(), MythSocketThread::ReadyToBeRead(), and setCallbacks().
bool MythSocket::m_useReadyReadCallback [protected] |
Definition at line 95 of file mythsocket.h.
Referenced by MythSocketThread::ReadyToBeRead().
State MythSocket::m_state [protected] |
Definition at line 96 of file mythsocket.h.
Referenced by setState(), and state().
QHostAddress MythSocket::m_addr [protected] |
Definition at line 97 of file mythsocket.h.
Referenced by Announce().
quint16 MythSocket::m_port [protected] |
Definition at line 98 of file mythsocket.h.
Referenced by Announce().
int MythSocket::m_ref_count [protected] |
Definition at line 99 of file mythsocket.h.
bool MythSocket::m_notifyread [protected] |
Definition at line 101 of file mythsocket.h.
Referenced by readBlock(), readStringList(), and MythSocketThread::ReadyToBeRead().
QMutex MythSocket::m_ref_lock [protected] |
Definition at line 102 of file mythsocket.h.
QMutex MythSocket::m_lock [mutable, protected] |
Definition at line 103 of file mythsocket.h.
bool MythSocket::m_expectingreply [protected] |
Definition at line 105 of file mythsocket.h.
Referenced by SendReceiveStringList().
bool MythSocket::m_isValidated [protected] |
Definition at line 106 of file mythsocket.h.
Referenced by Announce(), and Validate().
bool MythSocket::m_isAnnounced [protected] |
Definition at line 107 of file mythsocket.h.
Referenced by Announce(), and setAnnounce().
QStringList MythSocket::m_announce [protected] |
Definition at line 108 of file mythsocket.h.
Referenced by Announce(), and setAnnounce().
const uint MythSocket::kSocketBufferSize = 128000 [static, protected] |
Definition at line 110 of file mythsocket.h.
Referenced by connect(), MythSocket(), readData(), and writeData().
QMutex MythSocket::s_readyread_thread_lock [static, protected] |
Definition at line 111 of file mythsocket.h.
Referenced by MythSocket(), and ShutdownRRT().
MythSocketThread * MythSocket::s_readyread_thread = NULL [static, protected] |
Definition at line 112 of file mythsocket.h.
Referenced by connect(), DownRef(), Lock(), MythSocket(), readStringList(), setCallbacks(), ShutdownRRT(), TryLock(), and Unlock().
QMap< QString, QHostAddress::SpecialAddress > MythSocket::s_loopback_cache [static, protected] |
Definition at line 114 of file mythsocket.h.
Referenced by connect().
1.7.6.1