• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

KNetwork::KActiveSocketBase

KNetwork::KActiveSocketBase Class Reference

#include <k3socketbase.h>

Inheritance diagram for KNetwork::KActiveSocketBase:

Inheritance graph
[legend]

List of all members.


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 <thiago@kde.org>

Definition at line 459 of file k3socketbase.h.


Public Member Functions

virtual bool atEnd () const
virtual bool bind (const KResolverEntry &address)=0
virtual bool connect (const KResolverEntry &address, OpenMode mode=ReadWrite)=0
virtual bool disconnect ()=0
QString errorString () const
virtual bool isSequential () const
 KActiveSocketBase (QObject *parent)
virtual KSocketAddress localAddress () const =0
virtual bool open (OpenMode mode)
qint64 peek (char *data, qint64 maxlen, KSocketAddress &from)
qint64 peek (char *data, qint64 maxlen)
virtual KSocketAddress peerAddress () const =0
virtual qint64 pos () const
qint64 read (char *data, qint64 maxlen, KSocketAddress &from)
QByteArray read (qint64 len)
qint64 read (char *data, qint64 maxlen)
virtual bool seek (qint64)
virtual void setSocketDevice (KSocketDevice *device)
virtual qint64 size () const
void ungetChar (char)
virtual qint64 waitForMore (int msecs, bool *timeout=0L)=0
qint64 write (const char *data, qint64 len, const KSocketAddress &to)
qint64 write (const QByteArray &data)
qint64 write (const char *data, qint64 len)
virtual ~KActiveSocketBase ()

Protected Member Functions

virtual qint64 peekData (char *data, qint64 maxlen, KSocketAddress *from)=0
virtual qint64 readData (char *data, qint64 maxlen, KSocketAddress *from)=0
virtual qint64 readData (char *data, qint64 len)
void resetError ()
void setError (SocketError error)
virtual qint64 writeData (const char *data, qint64 len, const KSocketAddress *to)=0
virtual qint64 writeData (const char *data, qint64 len)

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 [virtual]

This call is not supported on sockets.

Reimplemented from QIODevice. This will always return true.

Definition at line 373 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:
address the address to bind to
Returns:
true if the binding was successful, false otherwise

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

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:
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::KClientSocketBase, KNetwork::KDatagramSocket, KNetwork::KSocketDevice, and KNetwork::KStreamSocket.

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.

Reimplemented from KNetwork::KSocketBase.

Definition at line 334 of file k3socketbase.cpp.

bool KActiveSocketBase::isSequential (  )  const [virtual]

Sockets are sequential.

Definition at line 353 of file k3socketbase.cpp.

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

Returns this socket's local address.

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

bool KActiveSocketBase::open ( OpenMode  mode  )  [virtual]

Reimplemented from QIODevice.

Reimplemented from QIODevice.

Reimplemented in KNetwork::KClientSocketBase.

Definition at line 339 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:
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 399 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:
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

Reimplemented from QIODevice.

Definition at line 394 of file k3socketbase.cpp.

virtual qint64 KNetwork::KActiveSocketBase::peekData ( char *  data,
qint64  maxlen,
KSocketAddress *  from 
) [protected, pure 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::KBufferedSocket, KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.

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, KNetwork::KHttpProxySocketDevice, KNetwork::KSocketDevice, and KNetwork::KSocksSocketDevice.

qint64 KActiveSocketBase::pos (  )  const [virtual]

This call is not supported on sockets.

Reimplemented from QIODevice. This will always return 0.

Definition at line 363 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:
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 388 of file k3socketbase.cpp.

QByteArray KActiveSocketBase::read ( qint64  len  ) 

Reads data from the socket.

Reimplemented from QIODevice. See QIODevice::read for more information.

Reimplemented from QIODevice.

Definition at line 383 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.

Reimplemented from QIODevice.

Definition at line 378 of file k3socketbase.cpp.

virtual qint64 KNetwork::KActiveSocketBase::readData ( char *  data,
qint64  maxlen,
KSocketAddress *  from 
) [protected, pure 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::KBufferedSocket, KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.

qint64 KActiveSocketBase::readData ( char *  data,
qint64  len 
) [protected, virtual]

Reads data from the socket.

Reimplemented from QIODevice. See QIODevice::readData for more information.

Reimplemented from QIODevice.

Definition at line 425 of file k3socketbase.cpp.

void KActiveSocketBase::resetError (  )  [protected]

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

Reimplemented from KNetwork::KSocketBase.

Definition at line 441 of file k3socketbase.cpp.

bool KActiveSocketBase::seek ( qint64   )  [virtual]

This call is not supported on sockets.

Reimplemented from QIODevice. This will always return false.

Reimplemented from QIODevice.

Definition at line 368 of file k3socketbase.cpp.

void KActiveSocketBase::setError ( SocketError  error  )  [protected]

Sets the socket's error code.

Parameters:
error the error code

Reimplemented from KNetwork::KSocketBase.

Definition at line 435 of file k3socketbase.cpp.

void KActiveSocketBase::setSocketDevice ( KSocketDevice *  device  )  [virtual]

Reimplemented from superclass.

Reimplemented from KNetwork::KSocketBase.

Reimplemented in KNetwork::KBufferedSocket.

Definition at line 347 of file k3socketbase.cpp.

qint64 KActiveSocketBase::size (  )  const [virtual]

This call is not supported on sockets.

Reimplemented from QIODevice. This will always return 0.

Definition at line 358 of file k3socketbase.cpp.

void KActiveSocketBase::ungetChar ( char   ) 

This call is not supported on sockets.

Reimplemented from QIODevice.

Reimplemented from QIODevice.

Definition at line 420 of file k3socketbase.cpp.

virtual qint64 KNetwork::KActiveSocketBase::waitForMore ( int  msecs,
bool *  timeout = 0L 
) [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::KBufferedSocket, KNetwork::KClientSocketBase, and KNetwork::KSocketDevice.

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 414 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.

Reimplemented from QIODevice.

Definition at line 409 of file k3socketbase.cpp.

qint64 KActiveSocketBase::write ( const char *  data,
qint64  len 
)

Writes the given data to the socket.

Reimplemented from QIODevice. See QIODevice::write for more information.

Reimplemented from QIODevice.

Definition at line 404 of file k3socketbase.cpp.

virtual qint64 KNetwork::KActiveSocketBase::writeData ( const char *  data,
qint64  len,
const KSocketAddress *  to 
) [protected, pure 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::KBufferedSocket, KNetwork::KClientSocketBase, KNetwork::KDatagramSocket, and KNetwork::KSocketDevice.

qint64 KActiveSocketBase::writeData ( const char *  data,
qint64  len 
) [protected, virtual]

Writes the given data to the socket.

Reimplemented from QIODevice. See QIODevice::writeData for more information.

Reimplemented from QIODevice.

Definition at line 430 of file k3socketbase.cpp.


The documentation for this class was generated from the following files:
  • k3socketbase.h
  • k3socketbase.cpp

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal