#include <kdatagramsocket.h>
Public Member Functions | |
KDatagramSocket (TQObject *parent=0L, const char *name=0L) | |
virtual | ~KDatagramSocket () |
virtual bool | bind (const TQString &node=TQString::null, const TQString &service=TQString::null) |
virtual bool | bind (const KResolverEntry &entry) |
virtual bool | connect (const TQString &node=TQString::null, const TQString &service=TQString::null) |
virtual bool | connect (const KResolverEntry &entry) |
virtual TQ_LONG | writeBlock (const char *data, TQ_ULONG len, const TDESocketAddress &to) |
virtual KDatagramPacket | receive () |
virtual TQ_LONG | send (const KDatagramPacket &packet) |
Public Member Functions inherited from KNetwork::KClientSocketBase | |
KClientSocketBase (TQObject *parent, const char *name) | |
virtual | ~KClientSocketBase () |
SocketState | state () const |
KResolver & | peerResolver () const |
const KResolverResults & | peerResults () const |
KResolver & | localResolver () const |
const KResolverResults & | localResults () const |
void | setResolutionEnabled (bool enable) |
void | setFamily (int families) |
virtual bool | lookup () |
void | connectToHost (const TQString &host, TQ_UINT16 port) |
virtual bool | disconnect () |
virtual bool | open (int) |
virtual void | close () |
virtual void | flush () |
virtual TQ_LONG | bytesAvailable () const |
virtual TQ_LONG | waitForMore (int msecs, bool *timeout=0L) |
virtual TQ_LONG | readBlock (char *data, TQ_ULONG maxlen) |
virtual TQ_LONG | readBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from) |
virtual TQ_LONG | peekBlock (char *data, TQ_ULONG maxlen) |
virtual TQ_LONG | peekBlock (char *data, TQ_ULONG maxlen, TDESocketAddress &from) |
virtual TQ_LONG | writeBlock (const char *data, TQ_ULONG len) |
virtual TDESocketAddress | localAddress () const |
virtual TDESocketAddress | peerAddress () const |
bool | emitsReadyRead () const |
virtual void | enableRead (bool enable) |
bool | emitsReadyWrite () const |
virtual void | enableWrite (bool enable) |
Public Member Functions inherited from KNetwork::KActiveSocketBase | |
KActiveSocketBase () | |
virtual | ~KActiveSocketBase () |
virtual Offset | size () const |
virtual Offset | at () const |
virtual bool | at (Offset) |
virtual bool | atEnd () const |
virtual int | getch () |
virtual int | putch (int ch) |
virtual int | ungetch (int) |
Public Member Functions inherited from KNetwork::TDESocketBase | |
TDESocketBase () | |
virtual | ~TDESocketBase () |
virtual bool | setBlocking (bool enable) |
bool | blocking () const |
virtual bool | setAddressReuseable (bool enable) |
bool | addressReuseable () const |
virtual bool | setIPv6Only (bool enable) |
bool | isIPv6Only () const |
virtual bool | setBroadcast (bool enable) |
bool | broadcast () const |
TDESocketDevice * | socketDevice () const |
virtual void | setSocketDevice (TDESocketDevice *device) |
int | setRequestedCapabilities (int add, int remove=0) |
SocketError | error () const |
TQString | errorString () const |
TQMutex * | mutex () const |
Additional Inherited Members | |
Public Types inherited from KNetwork::KClientSocketBase | |
enum | SocketState { Idle , HostLookup , HostFound , Bound , Connecting , Open , Closing , Unconnected = Bound , Connected = Open , Connection = Open } |
Public Types inherited from KNetwork::TDESocketBase | |
enum | SocketOptions { Blocking = 0x01 , AddressReuseable = 0x02 , IPv6Only = 0x04 , Keepalive = 0x08 , Broadcast = 0x10 } |
enum | SocketError { NoError = 0 , LookupFailure , AddressInUse , AlreadyCreated , AlreadyBound , AlreadyConnected , NotConnected , NotBound , NotCreated , WouldBlock , ConnectionRefused , ConnectionTimedOut , InProgress , NetFailure , NotSupported , Timeout , UnknownError , RemotelyDisconnected } |
Signals inherited from KNetwork::KClientSocketBase | |
void | stateChanged (int newstate) |
void | gotError (int code) |
void | hostFound () |
void | bound (const KResolverEntry &local) |
void | aboutToConnect (const KResolverEntry &remote, bool &skip) |
void | connected (const KResolverEntry &remote) |
void | closed () |
void | readyRead () |
void | readyWrite () |
Static Public Member Functions inherited from KNetwork::TDESocketBase | |
static TQString | errorString (SocketError code) |
static bool | isFatalError (int code) |
Protected Slots inherited from KNetwork::KClientSocketBase | |
virtual void | slotReadActivity () |
virtual void | slotWriteActivity () |
Protected Member Functions inherited from KNetwork::KClientSocketBase | |
virtual bool | setSocketOptions (int opts) |
void | setState (SocketState state) |
virtual void | stateChanging (SocketState newState) |
void | copyError () |
Protected Member Functions inherited from KNetwork::KActiveSocketBase | |
void | setError (int status, SocketError error) |
void | resetError () |
Protected Member Functions inherited from KNetwork::TDESocketBase | |
virtual int | socketOptions () const |
bool | hasDevice () const |
void | setError (SocketError error) |
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.
Definition at line 180 of file kdatagramsocket.h.
Constructor & Destructor Documentation
◆ KDatagramSocket()
KDatagramSocket::KDatagramSocket | ( | TQObject * | parent = 0L , |
const char * | name = 0L |
||
) |
Default constructor.
Definition at line 44 of file kdatagramsocket.cpp.
◆ ~KDatagramSocket()
|
virtual |
Member Function Documentation
◆ bind() [1/2]
|
inlinevirtual |
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 216 of file kdatagramsocket.h.
◆ bind() [2/2]
|
virtual |
Performs host lookups.
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.
◆ connect() [1/2]
|
inlinevirtual |
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 238 of file kdatagramsocket.h.
◆ connect() [2/2]
|
virtual |
"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 *, TQ_ULONG) ).
- Note
- Calling connect will not cause the socket to be bound. You have to call bind explicitly.
Implements KNetwork::KClientSocketBase.
Definition at line 92 of file kdatagramsocket.cpp.
◆ receive()
|
virtual |
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.
◆ send()
|
virtual |
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.
- Returns
- the number of bytes written or -1 in case of error.
Definition at line 168 of file kdatagramsocket.cpp.
◆ writeBlock()
|
virtual |
Writes data to the socket.
Reimplemented from KClientSocketBase.
Reimplemented from KNetwork::KClientSocketBase.
Definition at line 173 of file kdatagramsocket.cpp.
The documentation for this class was generated from the following files: