KNetwork::KActiveSocketBase
#include <k3socketbase.h>

Public Member Functions | |
KActiveSocketBase (QObject *parent) | |
~KActiveSocketBase () override | |
bool | atEnd () const override |
virtual bool | bind (const KResolverEntry &address)=0 |
virtual bool | connect (const KResolverEntry &address, OpenMode mode=ReadWrite)=0 |
virtual bool | disconnect ()=0 |
QString | errorString () const |
bool | isSequential () const override |
virtual KSocketAddress | localAddress () const =0 |
bool | open (OpenMode mode) override |
qint64 | peek (char *data, qint64 maxlen) |
qint64 | peek (char *data, qint64 maxlen, KSocketAddress &from) |
virtual KSocketAddress | peerAddress () const =0 |
qint64 | pos () const override |
qint64 | read (char *data, qint64 maxlen) |
qint64 | read (char *data, qint64 maxlen, KSocketAddress &from) |
QByteArray | read (qint64 len) |
bool | seek (qint64) override |
void | setSocketDevice (KSocketDevice *device) override |
qint64 | size () const override |
void | ungetChar (char) |
virtual qint64 | waitForMore (int msecs, bool *timeout=nullptr)=0 |
qint64 | write (const char *data, qint64 len) |
qint64 | write (const char *data, qint64 len, const KSocketAddress &to) |
qint64 | write (const QByteArray &data) |
![]() | |
QIODevice (QObject *parent) | |
void | aboutToClose () |
virtual qint64 | bytesAvailable () const const |
virtual qint64 | bytesToWrite () const const |
void | bytesWritten (qint64 bytes) |
virtual bool | canReadLine () const const |
void | channelBytesWritten (int channel, qint64 bytes) |
void | channelReadyRead (int channel) |
virtual void | close () |
void | commitTransaction () |
int | currentReadChannel () const const |
int | currentWriteChannel () const const |
QString | errorString () const const |
bool | getChar (char *c) |
bool | isOpen () const const |
bool | isReadable () const const |
bool | isTextModeEnabled () const const |
bool | isTransactionStarted () const const |
bool | isWritable () const const |
virtual bool | open (QIODevice::OpenMode mode) |
QIODevice::OpenMode | openMode () const const |
qint64 | peek (char *data, qint64 maxSize) |
QByteArray | peek (qint64 maxSize) |
bool | putChar (char c) |
qint64 | read (char *data, qint64 maxSize) |
QByteArray | read (qint64 maxSize) |
QByteArray | readAll () |
int | readChannelCount () const const |
void | readChannelFinished () |
qint64 | readLine (char *data, qint64 maxSize) |
QByteArray | readLine (qint64 maxSize) |
void | readyRead () |
virtual bool | reset () |
void | rollbackTransaction () |
void | setCurrentReadChannel (int channel) |
void | setCurrentWriteChannel (int channel) |
void | setTextModeEnabled (bool enabled) |
qint64 | skip (qint64 maxSize) |
void | startTransaction () |
void | ungetChar (char c) |
virtual bool | waitForBytesWritten (int msecs) |
virtual bool | waitForReadyRead (int msecs) |
qint64 | write (const char *data) |
qint64 | write (const char *data, qint64 maxSize) |
qint64 | write (const QByteArray &byteArray) |
int | writeChannelCount () const const |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
![]() | |
KSocketBase () | |
virtual | ~KSocketBase () |
bool | addressReuseable () const |
bool | blocking () const |
bool | broadcast () const |
SocketError | error () const |
QString | errorString () const |
bool | isIPv6Only () const |
QMutex * | mutex () const |
bool | noDelay () const |
virtual bool | setAddressReuseable (bool enable) |
virtual bool | setBlocking (bool enable) |
virtual bool | setBroadcast (bool enable) |
virtual bool | setIPv6Only (bool enable) |
virtual bool | setNoDelay (bool enable) |
int | setRequestedCapabilities (int add, int remove=0) |
KSocketDevice * | socketDevice () const |
Protected Member Functions | |
virtual qint64 | peekData (char *data, qint64 maxlen, KSocketAddress *from)=0 |
qint64 | readData (char *data, qint64 len) override |
virtual qint64 | readData (char *data, qint64 maxlen, KSocketAddress *from)=0 |
void | resetError () |
void | setError (SocketError error) |
qint64 | writeData (const char *data, qint64 len) override |
virtual qint64 | writeData (const char *data, qint64 len, const KSocketAddress *to)=0 |
![]() | |
virtual qint64 | readLineData (char *data, qint64 maxSize) |
void | setErrorString (const QString &str) |
void | setOpenMode (QIODevice::OpenMode openMode) |
![]() | |
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) |
![]() | |
bool | hasDevice () const |
void | resetError () |
void | setError (SocketError error) |
virtual bool | setSocketOptions (int opts) |
virtual int | socketOptions () const |
Additional Inherited Members | |
![]() | |
enum | OpenModeFlag |
![]() | |
enum | SocketError { NoError = 0, LookupFailure, AddressInUse, AlreadyCreated, AlreadyBound, AlreadyConnected, NotConnected, NotBound, NotCreated, WouldBlock, ConnectionRefused, ConnectionTimedOut, InProgress, NetFailure, NotSupported, Timeout, UnknownError, RemotelyDisconnected } |
enum | SocketOptions { Blocking = 0x01, AddressReuseable = 0x02, IPv6Only = 0x04, Keepalive = 0x08, Broadcast = 0x10, NoDelay = 0x20 } |
![]() | |
objectName | |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
static QString | errorString (SocketError code) |
static bool | isFatalError (int code) |
![]() | |
Append | |
ExistingOnly | |
NewOnly | |
NotOpen | |
typedef | OpenMode |
ReadOnly | |
ReadWrite | |
Text | |
Truncate | |
Unbuffered | |
WriteOnly | |
![]() | |
typedef | QObjectList |
Detailed Description
Abstract class for active sockets.
This class provides the standard interfaces for active sockets, i.e., sockets that are used to connect to external addresses.
- Deprecated:
- Use KSocketFactory or KLocalSocket instead
Definition at line 460 of file k3socketbase.h.
Constructor & Destructor Documentation
◆ KActiveSocketBase()
KActiveSocketBase::KActiveSocketBase | ( | QObject * | parent | ) |
Constructor.
Definition at line 325 of file k3socketbase.cpp.
◆ ~KActiveSocketBase()
|
override |
Destructor.
Definition at line 330 of file k3socketbase.cpp.
Member Function Documentation
◆ atEnd()
|
overridevirtual |
This call is not supported on sockets.
Reimplemented from QIODevice. This will always return true.
Reimplemented from QIODevice.
Definition at line 374 of file k3socketbase.cpp.
◆ bind()
|
pure virtual |
Binds this socket to the given address.
The socket will be constructed with the address family, socket type and protocol as those given in the address
object.
- Parameters
-
address the address to bind to
- Returns
- true if the binding was successful, false otherwise
Implemented in KNetwork::KStreamSocket, KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.
◆ connect()
|
pure virtual |
Connect to a remote host.
This will make this socket try to connect to the remote host. If the socket is not yet created, it will be created using the address family, socket type and protocol specified in the address
object.
If this function returns with error InProgress, calling it again with the same address after a time will cause it to test if the connection has succeeded in the mean time.
- Parameters
-
address the address to connect to mode mode for connection, from QIODevice
- Returns
- true if the connection was successful or has been successfully queued; false if an error occurred.
Implemented in KNetwork::KStreamSocket, KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.
◆ disconnect()
|
pure virtual |
Disconnects this socket from a connection, if possible.
If this socket was connected to an endpoint, the connection is severed, but the socket is not closed. If the socket wasn't connected, this function does nothing.
If the socket hadn't yet been created, this function does nothing either.
Not all socket types can disconnect. Most notably, only connectionless datagram protocols such as UDP support this operation.
- Returns
- true if the socket is now disconnected or false on error.
Implemented in KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.
◆ errorString()
QString KActiveSocketBase::errorString | ( | ) | const |
Unshadow errorString from QIODevice.
Definition at line 334 of file k3socketbase.cpp.
◆ isSequential()
|
overridevirtual |
Sockets are sequential.
Reimplemented from QIODevice.
Definition at line 354 of file k3socketbase.cpp.
◆ localAddress()
|
pure virtual |
Returns this socket's local address.
Implemented in KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.
◆ open()
|
override |
Reimplemented from QIODevice.
Definition at line 339 of file k3socketbase.cpp.
◆ peek() [1/2]
qint64 KActiveSocketBase::peek | ( | char * | data, |
qint64 | maxlen | ||
) |
Peeks the data in the socket and the source address.
This call will allow you to peek the data to be received without actually receiving it – that is, it will be available for further peekings and for the next read call.
- Parameters
-
data where to write the peeked data to maxlen the maximum number of bytes to peek
- Returns
- the actual number of bytes copied into
data
Definition at line 395 of file k3socketbase.cpp.
◆ peek() [2/2]
qint64 KActiveSocketBase::peek | ( | char * | data, |
qint64 | maxlen, | ||
KSocketAddress & | from | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Peeks the data in the socket and the source address.
This call will allow you to peek the data to be received without actually receiving it – that is, it will be available for further peekings and for the next read call.
- Parameters
-
data where to write the peeked data to maxlen the maximum number of bytes to peek from the address of the sender will be stored here
- Returns
- the actual number of bytes copied into
data
Definition at line 400 of file k3socketbase.cpp.
◆ peekData()
|
protectedpure virtual |
Peeks the data in the socket and the source address.
This call will allow you to peek the data to be received without actually receiving it – that is, it will be available for further peekings and for the next read call.
- Parameters
-
data where to write the peeked data to maxlen the maximum number of bytes to peek from the address of the sender will be stored here
- Returns
- the actual number of bytes copied into
data
Implemented in KNetwork::KSocketDevice, KNetwork::KClientSocketBase, and KNetwork::KBufferedSocket.
◆ peerAddress()
|
pure virtual |
Return this socket's peer address, if we are connected.
If the address cannot be retrieved, the returned object will contain an invalid address.
Implemented in KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.
◆ pos()
|
overridevirtual |
This call is not supported on sockets.
Reimplemented from QIODevice. This will always return 0.
Reimplemented from QIODevice.
Definition at line 364 of file k3socketbase.cpp.
◆ read() [1/3]
qint64 KActiveSocketBase::read | ( | char * | data, |
qint64 | maxlen | ||
) |
Reads data from the socket.
Reimplemented from QIODevice. See QIODevice::read for more information.
Definition at line 379 of file k3socketbase.cpp.
◆ read() [2/3]
qint64 KActiveSocketBase::read | ( | char * | data, |
qint64 | maxlen, | ||
KSocketAddress & | from | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Receives data and the source address.
This call will read data in the socket and will also place the sender's address in from
object.
- Parameters
-
data where to write the read data to maxlen the maximum number of bytes to read from the address of the sender will be stored here
- Returns
- the actual number of bytes read
Definition at line 389 of file k3socketbase.cpp.
◆ read() [3/3]
QByteArray KActiveSocketBase::read | ( | qint64 | len | ) |
Reads data from the socket.
Reimplemented from QIODevice. See QIODevice::read for more information.
Definition at line 384 of file k3socketbase.cpp.
◆ readData() [1/2]
|
overrideprotectedvirtual |
Reads data from the socket.
Reimplemented from QIODevice. See QIODevice::readData for more information.
Implements QIODevice.
Definition at line 426 of file k3socketbase.cpp.
◆ readData() [2/2]
|
protectedpure virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Receives data and the source address.
This call will read data in the socket and will also place the sender's address in from
object.
- Parameters
-
data where to write the read data to maxlen the maximum number of bytes to read from the address of the sender will be stored here
- Returns
- the actual number of bytes read
Implemented in KNetwork::KSocketDevice, KNetwork::KClientSocketBase, and KNetwork::KBufferedSocket.
◆ resetError()
|
protected |
Resets the socket error code and the I/O Device's status.
Definition at line 442 of file k3socketbase.cpp.
◆ seek()
|
overridevirtual |
This call is not supported on sockets.
Reimplemented from QIODevice. This will always return false.
Reimplemented from QIODevice.
Definition at line 369 of file k3socketbase.cpp.
◆ setError()
|
protected |
Sets the socket's error code.
- Parameters
-
error the error code
Definition at line 436 of file k3socketbase.cpp.
◆ setSocketDevice()
|
overridevirtual |
- Reimplemented from superclass.
Reimplemented from KNetwork::KSocketBase.
Definition at line 348 of file k3socketbase.cpp.
◆ size()
|
overridevirtual |
This call is not supported on sockets.
Reimplemented from QIODevice. This will always return 0.
Reimplemented from QIODevice.
Definition at line 359 of file k3socketbase.cpp.
◆ ungetChar()
void KActiveSocketBase::ungetChar | ( | char | ) |
This call is not supported on sockets.
Reimplemented from QIODevice.
Definition at line 421 of file k3socketbase.cpp.
◆ waitForMore()
|
pure virtual |
Waits up to msecs
for more data to be available on this socket.
If msecs is -1, this call will block indefinetely until more data is indeed available; if it's 0, this function returns immediately.
If timeout
is not NULL, this function will set it to indicate if a timeout occurred.
- Returns
- the number of bytes available
Implemented in KNetwork::KClientSocketBase, KNetwork::KSocketDevice, and KNetwork::KBufferedSocket.
◆ write() [1/3]
qint64 KActiveSocketBase::write | ( | const char * | data, |
qint64 | len | ||
) |
Writes the given data to the socket.
Reimplemented from QIODevice. See QIODevice::write for more information.
Definition at line 405 of file k3socketbase.cpp.
◆ write() [2/3]
qint64 KActiveSocketBase::write | ( | const char * | data, |
qint64 | len, | ||
const KSocketAddress & | to | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes the given data to the destination address.
Note that not all socket connections allow sending data to different addresses than the one the socket is connected to.
- Parameters
-
data the data to write len the length of the data to the address to send to
- Returns
- the number of bytes actually sent
Definition at line 415 of file k3socketbase.cpp.
◆ write() [3/3]
qint64 KActiveSocketBase::write | ( | const QByteArray & | data | ) |
Writes the given data to the socket.
Reimplemented from QIODevice. See QIODevice::write for more information.
Definition at line 410 of file k3socketbase.cpp.
◆ writeData() [1/2]
|
overrideprotectedvirtual |
Writes the given data to the socket.
Reimplemented from QIODevice. See QIODevice::writeData for more information.
Implements QIODevice.
Definition at line 431 of file k3socketbase.cpp.
◆ writeData() [2/2]
|
protectedpure virtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes the given data to the destination address.
Note that not all socket connections allow sending data to different addresses than the one the socket is connected to.
- Parameters
-
data the data to write len the length of the data to the address to send to
- Returns
- the number of bytes actually sent
Implemented in KNetwork::KSocketDevice, KNetwork::KClientSocketBase, and KNetwork::KBufferedSocket.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:56:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.