KNetwork::KDatagramSocket Class Reference
A socket that operates on datagrams. More...
#include <kdatagramsocket.h>
Inheritance diagram for KNetwork::KDatagramSocket:


Public Member Functions | |
KDatagramSocket (QObject *parent=0L, const char *name=0L) | |
virtual | ~KDatagramSocket () |
virtual bool | bind (const QString &node=QString::null, const QString &service=QString::null) |
virtual bool | bind (const KResolverEntry &entry) |
virtual bool | connect (const QString &node=QString::null, const QString &service=QString::null) |
virtual bool | connect (const KResolverEntry &entry) |
virtual KDatagramPacket | receive () |
virtual Q_LONG | send (const KDatagramPacket &packet) |
Detailed Description
A socket that operates on datagrams.Unlike KStreamSocket, which operates on a connection-based stream socket (generally TCP), this class and its descendants operates on datagrams, which are normally connectionless.
This class in specific provides easy access to the system's connectionless SOCK_DGRAM sockets.
- Author:
- Thiago Macieira <thiago.macieira@kdemail.net>
Definition at line 180 of file kdatagramsocket.h.
Constructor & Destructor Documentation
|
Default constructor.
Definition at line 44 of file kdatagramsocket.cpp. References QObject::connect(), KNetwork::KClientSocketBase::hostFound(), KNetwork::KClientSocketBase::localResolver(), KNetwork::KClientSocketBase::peerResolver(), KNetwork::KResolver::setFamily(), KNetwork::KResolver::setFlags(), and KNetwork::KResolver::setSocketType(). |
|
Destructor. This closes the socket. Definition at line 62 of file kdatagramsocket.cpp. |
Member Function Documentation
|
Binds this socket to the given address. If the socket is blocking, the socket will be bound when this function returns. Note that binding a socket is not necessary to be able to send datagrams. Some protocol families will use anonymous source addresses, while others will allocate an address automatically. Implements KNetwork::KClientSocketBase. Definition at line 69 of file kdatagramsocket.cpp. References KNetwork::KResolver::cancel(), KNetwork::KClientSocketBase::localResolver(), KNetwork::KClientSocketBase::lookup(), KNetwork::KResolver::setAddress(), and KNetwork::KClientSocketBase::state(). |
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Binds this socket to the given address. Reimplemented from KNetwork::KClientSocketBase. Definition at line 215 of file kdatagramsocket.h. |
|
"Connects" this socket to the given address. Note that connecting a datagram socket normally does not establish a permanent connection with the peer nor normally returns an error in case of failure. Connecting means only to designate the given address as the default destination address for datagrams sent without destination addresses (writeBlock(const char*, Q_LONG).
Implements KNetwork::KClientSocketBase. Definition at line 92 of file kdatagramsocket.cpp. References KNetwork::KClientSocketBase::lookup(), KNetwork::KClientSocketBase::peerResolver(), KNetwork::KResolver::setAddress(), KNetwork::KClientSocketBase::setState(), KNetwork::KClientSocketBase::state(), and KNetwork::KClientSocketBase::stateChanged(). |
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. "Connects" this socket to the given address. Reimplemented from KNetwork::KClientSocketBase. Definition at line 237 of file kdatagramsocket.h. |
|
Receives one datagram from the stream. The reading process is guaranteed to be atomical and not lose data from the packet. If nothing could be read, a null object will be returned. Definition at line 134 of file kdatagramsocket.cpp. References KNetwork::KSocketBase::blocking(), KNetwork::KClientSocketBase::bytesAvailable(), KNetwork::KClientSocketBase::gotError(), KNetwork::KClientSocketBase::readBlock(), KNetwork::KActiveSocketBase::setError(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KSocketDevice::waitForMore(). |
|
Sends one datagram into the stream. The destination address must be set if this socket has not been connected (see connect). The data in this packet will be sent only in one single datagram. If the system cannot send it like that, this function will fail. So, please take into consideration the datagram size limits.
Definition at line 168 of file kdatagramsocket.cpp. References KNetwork::KClientSocketBase::writeBlock(). |
The documentation for this class was generated from the following files: