KDECore
#include <k3socketbase.h>
Public Member Functions | |
KActiveSocketBase (QObject *parent) | |
virtual | ~KActiveSocketBase () |
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 |
virtual KSocketAddress | localAddress () const =0 |
virtual bool | open (OpenMode mode) |
qint64 | peek (char *data, qint64 maxlen) |
qint64 | peek (char *data, qint64 maxlen, KSocketAddress &from) |
virtual KSocketAddress | peerAddress () const =0 |
virtual qint64 | pos () const |
qint64 | read (char *data, qint64 maxlen) |
QByteArray | read (qint64 len) |
qint64 | read (char *data, qint64 maxlen, KSocketAddress &from) |
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) |
qint64 | write (const QByteArray &data) |
qint64 | write (const char *data, qint64 len, const KSocketAddress &to) |
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 |
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 |
virtual qint64 | readData (char *data, qint64 len) |
virtual qint64 | readData (char *data, qint64 maxlen, KSocketAddress *from)=0 |
void | resetError () |
void | setError (SocketError error) |
virtual qint64 | writeData (const char *data, qint64 len) |
virtual qint64 | writeData (const char *data, qint64 len, const KSocketAddress *to)=0 |
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 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 } |
Static Public Member Functions inherited from KNetwork::KSocketBase | |
static QString | errorString (SocketError code) |
static bool | isFatalError (int code) |
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 461 of file k3socketbase.h.
Constructor & Destructor Documentation
KActiveSocketBase::KActiveSocketBase | ( | QObject * | parent | ) |
Constructor.
Definition at line 325 of file k3socketbase.cpp.
|
virtual |
Destructor.
Definition at line 330 of file k3socketbase.cpp.
Member Function Documentation
|
virtual |
This call is not supported on sockets.
Reimplemented from QIODevice. This will always return true.
Definition at line 373 of file k3socketbase.cpp.
|
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::KDatagramSocket, KNetwork::KClientSocketBase, KNetwork::KStreamSocket, KNetwork::KSocketDevice, and KNetwork::KSocksSocketDevice.
|
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::KStreamSocket, and KNetwork::KSocketDevice.
|
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.
|
virtual |
Sockets are sequential.
Definition at line 353 of file k3socketbase.cpp.
|
pure virtual |
Returns this socket's local address.
Implemented in KNetwork::KClientSocketBase, KNetwork::KSocketDevice, and KNetwork::KSocksSocketDevice.
|
virtual |
Reimplemented from QIODevice.
Reimplemented in KNetwork::KClientSocketBase.
Definition at line 339 of file k3socketbase.cpp.
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 394 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.
|
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::KClientSocketBase, KNetwork::KSocketDevice, and KNetwork::KBufferedSocket.
|
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::KSocketDevice, KNetwork::KSocksSocketDevice, and KNetwork::KHttpProxySocketDevice.
|
virtual |
This call is not supported on sockets.
Reimplemented from QIODevice. This will always return 0.
Definition at line 363 of file k3socketbase.cpp.
Reads data from the socket.
Reimplemented from QIODevice. See QIODevice::read for more information.
Definition at line 378 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 383 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.
Reads data from the socket.
Reimplemented from QIODevice. See QIODevice::readData for more information.
Definition at line 425 of file k3socketbase.cpp.
|
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::KClientSocketBase, KNetwork::KSocketDevice, and KNetwork::KBufferedSocket.
|
protected |
Resets the socket error code and the I/O Device's status.
Definition at line 441 of file k3socketbase.cpp.
This call is not supported on sockets.
Reimplemented from QIODevice. This will always return false.
Definition at line 368 of file k3socketbase.cpp.
|
protected |
Sets the socket's error code.
- Parameters
-
error the error code
Definition at line 435 of file k3socketbase.cpp.
|
virtual |
- Reimplemented from superclass.
Reimplemented from KNetwork::KSocketBase.
Reimplemented in KNetwork::KBufferedSocket.
Definition at line 347 of file k3socketbase.cpp.
|
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.
Definition at line 420 of file k3socketbase.cpp.
|
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.
Writes the given data to the socket.
Reimplemented from QIODevice. See QIODevice::write for more information.
Definition at line 404 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 409 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
-
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.
Writes the given data to the socket.
Reimplemented from QIODevice. See QIODevice::writeData for more information.
Definition at line 430 of file k3socketbase.cpp.
|
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::KClientSocketBase, KNetwork::KSocketDevice, KNetwork::KDatagramSocket, and KNetwork::KBufferedSocket.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.