KNetwork::KActiveSocketBase

KNetwork::KActiveSocketBase Class Referenceabstract

#include <k3socketbase.h>

Inheritance diagram for KNetwork::KActiveSocketBase:

Public Member Functions

 KActiveSocketBase (QObject *parent)
 
virtual ~KActiveSocketBase ()
 
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)
 
QByteArray read (qint64 len)
 
qint64 read (char *data, qint64 maxlen, KSocketAddress &from)
 
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 QByteArray &data)
 
qint64 write (const char *data, qint64 len, const KSocketAddress &to)
 
- Public Member Functions inherited from QIODevice
 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 ()
 
QByteArray readLine (qint64 maxSize)
 
qint64 readLine (char *data, 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 QByteArray &byteArray)
 
qint64 write (const char *data, qint64 maxSize)
 
int writeChannelCount () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () 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< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, 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 QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () 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
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const 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)
 
QThreadthread () const const
 
- Public Member Functions inherited from KNetwork::KSocketBase
 KSocketBase ()
 
virtual ~KSocketBase ()
 
bool addressReuseable () const
 
bool blocking () const
 
bool broadcast () const
 
SocketError error () const
 
QString errorString () const
 
bool isIPv6Only () const
 
QMutexmutex () 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)
 
KSocketDevicesocketDevice () 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
 
- Protected Member Functions inherited from QIODevice
virtual qint64 readLineData (char *data, qint64 maxSize)
 
void setErrorString (const QString &str)
 
void setOpenMode (QIODevice::OpenMode openMode)
 
- 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
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Member Functions inherited from KNetwork::KSocketBase
bool hasDevice () const
 
void resetError ()
 
void setError (SocketError error)
 
virtual bool setSocketOptions (int opts)
 
virtual int socketOptions () const
 

Additional Inherited Members

- Public Types inherited from QIODevice
enum  OpenModeFlag
 
- Public Types inherited from KNetwork::KSocketBase
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
}
 
- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
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 *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
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, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Public Member Functions inherited from KNetwork::KSocketBase
static QString errorString (SocketError code)
 
static bool isFatalError (int code)
 
- Public Attributes inherited from QIODevice
 Append
 
 ExistingOnly
 
 NewOnly
 
 NotOpen
 
typedef OpenMode
 
 ReadOnly
 
 ReadWrite
 
 Text
 
 Truncate
 
 Unbuffered
 
 WriteOnly
 
- Public Attributes inherited from QObject
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.

Author
Thiago Macieira thiag[email protected][email protected][email protected]e.org
Deprecated:
Use KSocketFactory or KLocalSocket instead

Definition at line 460 of file k3socketbase.h.

Constructor & Destructor Documentation

KActiveSocketBase::KActiveSocketBase ( QObject parent)

Constructor.

Definition at line 325 of file k3socketbase.cpp.

KActiveSocketBase::~KActiveSocketBase ( )
virtual

Destructor.

Definition at line 330 of file k3socketbase.cpp.

Member Function Documentation

bool KActiveSocketBase::atEnd ( ) const
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.

virtual bool KNetwork::KActiveSocketBase::bind ( const KResolverEntry address)
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
addressthe address to bind to
Returns
true if the binding was successful, false otherwise

Implemented in KNetwork::KClientSocketBase, KNetwork::KStreamSocket, and KNetwork::KSocketDevice.

virtual bool KNetwork::KActiveSocketBase::connect ( const KResolverEntry address,
OpenMode  mode = ReadWrite 
)
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
addressthe address to connect to
modemode for connection, from QIODevice
Returns
true if the connection was successful or has been successfully queued; false if an error occurred.

Implemented in KNetwork::KClientSocketBase, KNetwork::KStreamSocket, and KNetwork::KSocketDevice.

virtual bool KNetwork::KActiveSocketBase::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.

QString KActiveSocketBase::errorString ( ) const

Unshadow errorString from QIODevice.

Definition at line 334 of file k3socketbase.cpp.

bool KActiveSocketBase::isSequential ( ) const
overridevirtual

Sockets are sequential.

Reimplemented from QIODevice.

Definition at line 354 of file k3socketbase.cpp.

virtual KSocketAddress KNetwork::KActiveSocketBase::localAddress ( ) const
pure virtual

Returns this socket's local address.

Implemented in KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.

bool KActiveSocketBase::open ( OpenMode  mode)
override

Reimplemented from QIODevice.

Definition at line 339 of file k3socketbase.cpp.

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
datawhere to write the peeked data to
maxlenthe maximum number of bytes to peek
Returns
the actual number of bytes copied into data

Definition at line 395 of file k3socketbase.cpp.

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
datawhere to write the peeked data to
maxlenthe maximum number of bytes to peek
fromthe 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.

virtual qint64 KNetwork::KActiveSocketBase::peekData ( char *  data,
qint64  maxlen,
KSocketAddress from 
)
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
datawhere to write the peeked data to
maxlenthe maximum number of bytes to peek
fromthe address of the sender will be stored here
Returns
the actual number of bytes copied into data

Implemented in KNetwork::KClientSocketBase, KNetwork::KSocketDevice, and KNetwork::KBufferedSocket.

virtual KSocketAddress KNetwork::KActiveSocketBase::peerAddress ( ) const
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.

qint64 KActiveSocketBase::pos ( ) const
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.

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.

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.

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
datawhere to write the read data to
maxlenthe maximum number of bytes to read
fromthe address of the sender will be stored here
Returns
the actual number of bytes read

Definition at line 389 of file k3socketbase.cpp.

qint64 KActiveSocketBase::readData ( char *  data,
qint64  len 
)
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.

virtual qint64 KNetwork::KActiveSocketBase::readData ( char *  data,
qint64  maxlen,
KSocketAddress from 
)
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
datawhere to write the read data to
maxlenthe maximum number of bytes to read
fromthe address of the sender will be stored here
Returns
the actual number of bytes read

Implemented in KNetwork::KClientSocketBase, KNetwork::KSocketDevice, and KNetwork::KBufferedSocket.

void KActiveSocketBase::resetError ( )
protected

Resets the socket error code and the I/O Device's status.

Definition at line 442 of file k3socketbase.cpp.

bool KActiveSocketBase::seek ( qint64  )
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.

void KActiveSocketBase::setError ( SocketError  error)
protected

Sets the socket's error code.

Parameters
errorthe error code

Definition at line 436 of file k3socketbase.cpp.

void KActiveSocketBase::setSocketDevice ( KSocketDevice device)
overridevirtual
Reimplemented from superclass.

Reimplemented from KNetwork::KSocketBase.

Definition at line 348 of file k3socketbase.cpp.

qint64 KActiveSocketBase::size ( ) const
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.

void KActiveSocketBase::ungetChar ( char  )

This call is not supported on sockets.

Reimplemented from QIODevice.

Definition at line 421 of file k3socketbase.cpp.

virtual qint64 KNetwork::KActiveSocketBase::waitForMore ( int  msecs,
bool *  timeout = nullptr 
)
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.

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.

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.

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
datathe data to write
lenthe length of the data
tothe address to send to
Returns
the number of bytes actually sent

Definition at line 415 of file k3socketbase.cpp.

qint64 KActiveSocketBase::writeData ( const char *  data,
qint64  len 
)
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.

virtual qint64 KNetwork::KActiveSocketBase::writeData ( const char *  data,
qint64  len,
const KSocketAddress to 
)
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
datathe data to write
lenthe length of the data
tothe address to send to
Returns
the number of bytes actually sent

Implemented in KNetwork::KClientSocketBase, KNetwork::KSocketDevice, and KNetwork::KBufferedSocket.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 14 2020 22:58:43 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.