KMessageSocket
#include <KGame/KMessageIO>
Protected Slots | |
virtual void | processNewData () |
Protected Member Functions | |
void | initSocket () |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
bool | isRecursive |
bool | mAwaitingHeader |
quint32 | mNextBlockLength |
QTcpSocket * | mSocket |
Protected Attributes inherited from KMessageIO | |
quint32 | m_id |
Detailed Description
This class implements the message communication using a TCP/IP socket.
The object can connect to a server socket, or can use an already connected socket.
Definition at line 149 of file kmessageio.h.
Constructor & Destructor Documentation
◆ KMessageSocket() [1/4]
Connects to a server socket on /e host with /e port.
host can be an numerical (e.g. "192.168.0.212") or symbolic (e.g. "wave.peter.org") IP address. You can immediately use the /e sendSystem() and /e sendBroadcast() methods. The messages are stored and sent to the receiver after the connection is established.
If the connection could not be established (e.g. unknown host or no server socket at this port), the signal /e connectionBroken is emitted.
Definition at line 67 of file kmessageio.cpp.
◆ KMessageSocket() [2/4]
KMessageSocket::KMessageSocket | ( | const QHostAddress & | host, |
quint16 | port, | ||
QObject * | parent = nullptr ) |
Connects to a server socket on /e host with /e port.
You can immediately use the /e sendSystem() and /e sendBroadcast() methods. The messages are stored and sent to the receiver after the connection is established.
If the connection could not be established (e.g. unknown host or no server socket at this port), the signal /e connectionBroken is emitted.
Definition at line 75 of file kmessageio.cpp.
◆ KMessageSocket() [3/4]
|
explicit |
Uses /e socket to do the communication.
The socket should already be connected, or at least be in /e connecting state.
Note: The /e socket object is then owned by the /e KMessageSocket object. So don't use it otherwise any more and don't delete it. It is deleted together with this KMessageSocket object. (Use 0 as parent for the QSocket object t ensure it is not deleted.)
Definition at line 83 of file kmessageio.cpp.
◆ KMessageSocket() [4/4]
Uses the socket specified by the socket descriptor socketFD to do the communication.
The socket must already be connected.
This constructor can be used with a QServerSocket within the (pure virtual) method /e newConnection.
Note: The socket is then owned by the /e KMessageSocket object. So don't manipulate the socket afterwards, especially don't close it. The socket is automatically closed when KMessageSocket is deleted.
Definition at line 90 of file kmessageio.cpp.
◆ ~KMessageSocket()
|
override |
Destructor, closes the socket.
Definition at line 98 of file kmessageio.cpp.
Member Function Documentation
◆ initSocket()
|
protected |
Definition at line 163 of file kmessageio.cpp.
◆ isConnected()
|
overridevirtual |
Returns true if the socket is in state /e connected.
Reimplemented from KMessageIO.
Definition at line 103 of file kmessageio.cpp.
◆ isNetwork()
|
inlineoverridevirtual |
- Returns
- TRUE as this is a network IO.
Reimplemented from KMessageIO.
Definition at line 228 of file kmessageio.h.
◆ peerName()
|
overridevirtual |
- Returns
- The hostname this object is connected to. See QSocket::peerName.
Reimplemented from KMessageIO.
Definition at line 178 of file kmessageio.cpp.
◆ peerPort()
|
overridevirtual |
- Returns
- The port that this object is connected to. See QSocket::peerPort
Reimplemented from KMessageIO.
Definition at line 173 of file kmessageio.cpp.
◆ processNewData
|
protectedvirtualslot |
Definition at line 115 of file kmessageio.cpp.
◆ rtti()
|
inlineoverridevirtual |
The runtime identification.
Reimplemented from KMessageIO.
Definition at line 210 of file kmessageio.h.
◆ send()
|
overridevirtual |
Overwritten slot method from KMessageIO.
Note: It is not declared as a slot method, since the slot is already defined in KMessageIO as a virtual method.
Implements KMessageIO.
Definition at line 108 of file kmessageio.cpp.
Member Data Documentation
◆ isRecursive
|
protected |
Definition at line 255 of file kmessageio.h.
◆ mAwaitingHeader
|
protected |
Definition at line 252 of file kmessageio.h.
◆ mNextBlockLength
|
protected |
Definition at line 253 of file kmessageio.h.
◆ mSocket
|
protected |
Definition at line 251 of file kmessageio.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:16:50 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.