KNetwork::KClientSocketBase

KNetwork::KClientSocketBase Class Referenceabstract

#include <k3clientsocketbase.h>

Inheritance diagram for KNetwork::KClientSocketBase:

Public Types

enum  SocketState {
  Idle, HostLookup, HostFound, Bound,
  Connecting, Open, Closing, Unconnected = Bound,
  Connected = Open, Connection = Open
}
 
- 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
}
 

Signals

void aboutToConnect (const KNetwork::KResolverEntry &remote, bool &skip)
 
void bound (const KNetwork::KResolverEntry &local)
 
void closed ()
 
void connected (const KNetwork::KResolverEntry &remote)
 
void gotError (int code)
 
void hostFound ()
 
void readyWrite ()
 
void stateChanged (int newstate)
 

Public Member Functions

 KClientSocketBase (QObject *parent)
 
virtual ~KClientSocketBase ()
 
virtual bool bind (const QString &node=QString(), const QString &service=QString())=0
 
bool bind (const KResolverEntry &address) override
 
qint64 bytesAvailable () const override
 
void close () override
 
virtual bool connect (const QString &node=QString(), const QString &service=QString(), OpenMode mode=ReadWrite)=0
 
virtual bool connect (const KResolverEntry &address, OpenMode mode=ReadWrite) override
 
bool disconnect () override
 
bool emitsReadyRead () const
 
bool emitsReadyWrite () const
 
virtual void enableRead (bool enable)
 
virtual void enableWrite (bool enable)
 
virtual bool flush ()
 
KSocketAddress localAddress () const override
 
KResolverlocalResolver () const
 
const KResolverResultslocalResults () const
 
virtual bool lookup ()
 
bool open (OpenMode mode) override
 
KSocketAddress peerAddress () const override
 
KResolverpeerResolver () const
 
const KResolverResultspeerResults () const
 
void setFamily (int families)
 
void setResolutionEnabled (bool enable)
 
SocketState state () const
 
qint64 waitForMore (int msecs, bool *timeout=nullptr) override
 
- Public Member Functions inherited from KNetwork::KActiveSocketBase
 KActiveSocketBase (QObject *parent)
 
virtual ~KActiveSocketBase ()
 
bool atEnd () const override
 
QString errorString () const
 
bool isSequential () const override
 
bool open (OpenMode mode) override
 
qint64 peek (char *data, qint64 maxlen)
 
qint64 peek (char *data, qint64 maxlen, KSocketAddress &from)
 
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)
 
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 bytesToWrite () const const
 
void bytesWritten (qint64 bytes)
 
virtual bool canReadLine () const const
 
void channelBytesWritten (int channel, qint64 bytes)
 
void channelReadyRead (int channel)
 
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 Slots

virtual void slotReadActivity ()
 
virtual void slotWriteActivity ()
 

Protected Member Functions

void copyError ()
 
qint64 peekData (char *data, qint64 maxlen, KSocketAddress *from) override
 
qint64 readData (char *data, qint64 maxlen, KSocketAddress *from) override
 
bool setSocketOptions (int opts) override
 
void setState (SocketState state)
 
virtual void stateChanging (SocketState newState)
 
qint64 writeData (const char *data, qint64 len, const KSocketAddress *to) override
 
- Protected Member Functions inherited from KNetwork::KActiveSocketBase
qint64 readData (char *data, qint64 len) override
 
void resetError ()
 
void setError (SocketError error)
 
qint64 writeData (const char *data, qint64 len) override
 
- 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 int socketOptions () const
 

Additional Inherited Members

- 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 client socket class.

This class provides the base functionality for client sockets, such as, and especially, name resolution and signals.

Note
This class is abstract. If you're looking for a normal, client socket class, see KStreamSocket and KBufferedSocket
Author
Thiago Macieira thiag[email protected][email protected][email protected]e.org
Deprecated:
Use KSocketFactory or KLocalSocket instead

Definition at line 51 of file k3clientsocketbase.h.

Member Enumeration Documentation

Socket states.

These are the possible states for a KClientSocketBase:

  • Idle: socket is not connected
  • HostLookup: socket is doing host lookup prior to connecting
  • HostFound: name lookup is complete
  • Bound: the socket is locally bound
  • Connecting: socket is attempting connection
  • Open: socket is open
  • Connected (=Open): socket is connected
  • Connection (=Open): yet another name for a connected socket
  • Closing: socket is shutting down

Whenever the socket state changes, the stateChanged(int) signal will be emitted.

Definition at line 73 of file k3clientsocketbase.h.

Constructor & Destructor Documentation

KClientSocketBase::KClientSocketBase ( QObject parent)

Default constructor.

Parameters
parentthe parent QObject object

Definition at line 51 of file k3clientsocketbase.cpp.

KClientSocketBase::~KClientSocketBase ( )
virtual

Destructor.

Definition at line 59 of file k3clientsocketbase.cpp.

Member Function Documentation

void KNetwork::KClientSocketBase::aboutToConnect ( const KNetwork::KResolverEntry remote,
bool &  skip 
)
signal

This signal is emitted when the socket is about to connect to an address (but before doing so).

The skip parameter can be used to make the loop skip this address. Its value is initially false: change it to true if you want to skip the current address (as given by remote).

This function is also useful if one wants to reset the timeout.

Parameters
remotethe address we're about to connect to
skipset to true if you want to skip this address
Note
if the connection is successful, the connected() signal will be emitted.
virtual bool KNetwork::KClientSocketBase::bind ( const QString node = QString(),
const QString service = QString() 
)
pure virtual

Binds this socket to the given nodename and service, or use the default ones if none are given.

Upon successful binding, the bound() signal will be emitted. If an error is found, the gotError() signal will be emitted.

Note
Due to the internals of the name lookup and binding mechanism, some (if not most) implementations of this function do not actually bind the socket until the connection is requested (see connect()). They only set the values for future reference.

This function returns true on success.

Parameters
nodethe nodename
servicethe service

Implemented in KNetwork::KStreamSocket.

bool KClientSocketBase::bind ( const KResolverEntry address)
overridevirtual

Reimplemented from KSocketBase.

Connect this socket to this specific address.

Unlike bind(const QString&, const QString&) above, this function really does bind the socket. No lookup is performed. The bound() signal will be emitted.

Implements KNetwork::KActiveSocketBase.

Reimplemented in KNetwork::KStreamSocket.

Definition at line 189 of file k3clientsocketbase.cpp.

void KNetwork::KClientSocketBase::bound ( const KNetwork::KResolverEntry local)
signal

This signal is emitted when the socket successfully binds to an address.

Parameters
localthe local address we bound to
qint64 KClientSocketBase::bytesAvailable ( ) const
overridevirtual

Returns the number of bytes available on this socket.

Reimplemented from KSocketBase.

Reimplemented from QIODevice.

Definition at line 291 of file k3clientsocketbase.cpp.

void KClientSocketBase::close ( )
overridevirtual

Closes the socket.

Reimplemented from QIODevice.

The closing of the socket causes the emission of the signal closed().

Reimplemented from QIODevice.

Definition at line 265 of file k3clientsocketbase.cpp.

void KNetwork::KClientSocketBase::closed ( )
signal

This signal is emitted when the socket completes the closing/shut down process.

virtual bool KNetwork::KClientSocketBase::connect ( const QString node = QString(),
const QString service = QString(),
OpenMode  mode = ReadWrite 
)
pure virtual

Attempts to connect to a given hostname and service, or use the default ones if none are given.

If a connection attempt is already in progress, check on its state and set the error status (NoError or InProgress).

If the blocking mode for this object is on, this function will only return when all the resolved peer addresses have been tried or when a connection is established.

Upon successfully connecting, the connected() signal will be emitted. If an error is found, the gotError() signal will be emitted.

Note for derived classes:
Derived classes must implement this function. The implementation will set the parameters for the lookup (using the peer KResolver object) and call lookup() to start it.
The implementation should use the hostFound() signal to be notified of the completion of the lookup process and then proceed to start the connection itself. Care should be taken regarding the value of blocking() flag.
Parameters
nodethe nodename (host to connect to)
servicethe service to connect to
modethe mode to open the connection in

Implemented in KNetwork::KStreamSocket.

bool KClientSocketBase::connect ( const KResolverEntry address,
OpenMode  mode = ReadWrite 
)
overridevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Reimplemented from KSocketBase.

Implements KNetwork::KActiveSocketBase.

Reimplemented in KNetwork::KStreamSocket.

Definition at line 209 of file k3clientsocketbase.cpp.

void KNetwork::KClientSocketBase::connected ( const KNetwork::KResolverEntry remote)
signal

This socket is emitted when the socket successfully connects to a remote address.

Parameters
remotethe remote address we did connect to
void KClientSocketBase::copyError ( )
protected

Convenience function to set this object's error code to match that of the socket device.

Definition at line 445 of file k3clientsocketbase.cpp.

bool KClientSocketBase::disconnect ( )
overridevirtual

Disconnects the socket.

Note that not all socket types can disconnect.

Implements KNetwork::KActiveSocketBase.

Definition at line 243 of file k3clientsocketbase.cpp.

bool KClientSocketBase::emitsReadyRead ( ) const

Returns true if the readyRead signal is set to be emitted.

Definition at line 355 of file k3clientsocketbase.cpp.

bool KClientSocketBase::emitsReadyWrite ( ) const

Returns true if the readyWrite signal is set to be emitted.

Definition at line 371 of file k3clientsocketbase.cpp.

void KClientSocketBase::enableRead ( bool  enable)
virtual

Enables the emission of the readyRead signal.

By default, this signal is enabled.

Parameters
enablewhether to enable the signal

Reimplemented in KNetwork::KBufferedSocket.

Definition at line 360 of file k3clientsocketbase.cpp.

void KClientSocketBase::enableWrite ( bool  enable)
virtual

Enables the emission of the readyWrite signal.

By default, this signal is disabled.

Parameters
enablewhether to enable the signal

Reimplemented in KNetwork::KBufferedSocket.

Definition at line 376 of file k3clientsocketbase.cpp.

bool KClientSocketBase::flush ( )
virtual

This call is not supported on unbuffered sockets.

Reimplemented from QIODevice.

Definition at line 285 of file k3clientsocketbase.cpp.

void KNetwork::KClientSocketBase::gotError ( int  code)
signal

This signal is emitted when this object finds an error.

The code parameter contains the error code that can also be found by calling error().

void KNetwork::KClientSocketBase::hostFound ( )
signal

This signal is emitted when the lookup is successfully completed.

KSocketAddress KClientSocketBase::localAddress ( ) const
overridevirtual

Returns the local socket address.

Reimplemented from KSocketBase.

Implements KNetwork::KActiveSocketBase.

Definition at line 345 of file k3clientsocketbase.cpp.

KResolver & KClientSocketBase::localResolver ( ) const

Returns the internal KResolver object used for looking up the local host name and service.

This can be used to set extra options to the lookup process other than the default values, as well as obtaining the error codes in case of lookup failure.

Definition at line 101 of file k3clientsocketbase.cpp.

const KResolverResults & KClientSocketBase::localResults ( ) const

Returns the internal list of resolved results for the local address.

Definition at line 106 of file k3clientsocketbase.cpp.

bool KClientSocketBase::lookup ( )
virtual

Starts the lookup for peer and local hostnames as well as their services.

If the blocking mode for this object is on, this function will wait for the lookup results to be available (by calling the KResolver::wait() method on the resolver objects).

When the lookup is done, the signal hostFound() will be emitted (only once, even if we're doing a double lookup). If the lookup failed (for any of the two lookups) the gotError() signal will be emitted with the appropriate error condition (see KSocketBase::SocketError).

This function returns true on success and false on error. Note that this is not the lookup result!

Definition at line 128 of file k3clientsocketbase.cpp.

bool KClientSocketBase::open ( OpenMode  mode)
override

Opens the socket.

Reimplemented from QIODevice.

You should not call this function; instead, use connect()

Definition at line 260 of file k3clientsocketbase.cpp.

qint64 KClientSocketBase::peekData ( char *  data,
qint64  maxlen,
KSocketAddress from 
)
overrideprotectedvirtual

Peeks data from the socket.

Reimplemented from KSocketBase.

Implements KNetwork::KActiveSocketBase.

Definition at line 321 of file k3clientsocketbase.cpp.

KSocketAddress KClientSocketBase::peerAddress ( ) const
overridevirtual

Returns the peer socket address.

Reimplemented from KSocketBase.

Implements KNetwork::KActiveSocketBase.

Definition at line 350 of file k3clientsocketbase.cpp.

KResolver & KClientSocketBase::peerResolver ( ) const

Returns the internal KResolver object used for looking up the peer host name and service.

This can be used to set extra options to the lookup process other than the default values, as well as obtaining the error codes in case of lookup failure.

Definition at line 91 of file k3clientsocketbase.cpp.

const KResolverResults & KClientSocketBase::peerResults ( ) const

Returns the internal list of resolved results for the peer address.

Definition at line 96 of file k3clientsocketbase.cpp.

qint64 KClientSocketBase::readData ( char *  data,
qint64  maxlen,
KSocketAddress from 
)
overrideprotectedvirtual

Reads data from a socket.

Reimplemented from KSocketBase.

Implements KNetwork::KActiveSocketBase.

Definition at line 310 of file k3clientsocketbase.cpp.

void KNetwork::KClientSocketBase::readyWrite ( )
signal

This signal is emitted whenever the socket is ready for writing – i.e., whenever there's space available in the buffers to receive more data.

The subsequent write operation is guaranteed to be non-blocking.

You can toggle the emission of this signal with the enableWrite() function. This signal is by default disabled. You will want to disable this signal after the first reception, since it'll probably fire at every event loop.

void KClientSocketBase::setFamily ( int  families)

Sets the allowed families for the resolutions.

Parameters
familiesthe families that we want/accept
See also
KResolver::SocketFamilies for possible values

Definition at line 122 of file k3clientsocketbase.cpp.

void KClientSocketBase::setResolutionEnabled ( bool  enable)

Enables or disables name resolution.

If this flag is set to true, bind() and connect() operations will trigger name lookup operations (i.e., converting a hostname into its binary form). If the flag is set to false, those operations will instead try to convert a string representation of an address without attempting name resolution.

This is useful, for instance, when IP addresses are in their string representation (such as "1.2.3.4") or come from other sources like KSocketAddress.

Parameters
enablewhether to enable

Definition at line 111 of file k3clientsocketbase.cpp.

bool KClientSocketBase::setSocketOptions ( int  opts)
overrideprotectedvirtual

Sets the socket options.

Reimplemented from KSocketBase.

Reimplemented from KNetwork::KSocketBase.

Definition at line 76 of file k3clientsocketbase.cpp.

void KClientSocketBase::setState ( SocketState  state)
protected

Sets the socket state to state.

This function does not emit the stateChanged() signal.

Definition at line 70 of file k3clientsocketbase.cpp.

void KClientSocketBase::slotReadActivity ( )
protectedvirtualslot

This slot is connected to the read notifier's signal meaning the socket can read more data.

The default implementation only emits the readyRead signal.

Override if your class requires processing of incoming data.

Definition at line 387 of file k3clientsocketbase.cpp.

void KClientSocketBase::slotWriteActivity ( )
protectedvirtualslot

This slot is connected to the write notifier's signal meaning the socket can write more data.

The default implementation only emits the readyWrite signal.

Override if your class writes data from another source (like a buffer).

Definition at line 394 of file k3clientsocketbase.cpp.

KClientSocketBase::SocketState KClientSocketBase::state ( ) const

Returns the current state for this socket.

See also
SocketState

Definition at line 65 of file k3clientsocketbase.cpp.

void KNetwork::KClientSocketBase::stateChanged ( int  newstate)
signal

This signal is emitted whenever the socket state changes.

Note: do not delete this object inside the slot called by this signal.

Parameters
newstatethe new state of the socket object
void KClientSocketBase::stateChanging ( SocketState  newState)
protectedvirtual

This function is called by setState() whenever the state changes.

You should override it if you need to specify any actions to be done when the state changes.

The default implementation acts for these states only:

  • Connected: it sets up the socket notifiers to fire readyRead and readyWrite signals.

Reimplemented in KNetwork::KBufferedSocket.

Definition at line 424 of file k3clientsocketbase.cpp.

qint64 KClientSocketBase::waitForMore ( int  msecs,
bool *  timeout = nullptr 
)
overridevirtual

Waits for more data.

Reimplemented from KSocketBase.

Implements KNetwork::KActiveSocketBase.

Definition at line 299 of file k3clientsocketbase.cpp.

qint64 KClientSocketBase::writeData ( const char *  data,
qint64  len,
const KSocketAddress to 
)
overrideprotectedvirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Writes data to the socket.

Reimplemented from KSocketBase.

Implements KNetwork::KActiveSocketBase.

Definition at line 332 of file k3clientsocketbase.cpp.


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 Mon Jul 13 2020 22:58:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.