• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • KNetwork
  • KDatagramSocket
Public Member Functions
KNetwork::KDatagramSocket Class Reference

#include <kdatagramsocket.h>

Inheritance diagram for KNetwork::KDatagramSocket:
KNetwork::KClientSocketBase TQObject KNetwork::KMulticastSocket

List of all members.

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 tqwriteBlock (const char *data, TQ_ULONG len, const TDESocketAddress &to)
virtual KDatagramPacket receive ()
virtual TQ_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

KDatagramSocket::KDatagramSocket ( TQObject *  parent = 0L,
const char *  name = 0L 
)

Default constructor.

Definition at line 44 of file kdatagramsocket.cpp.

KDatagramSocket::~KDatagramSocket ( ) [virtual]

Destructor.

This closes the socket.

Definition at line 62 of file kdatagramsocket.cpp.


Member Function Documentation

bool KDatagramSocket::bind ( const TQString &  node = TQString::null,
const TQString &  service = TQString::null 
) [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.

virtual bool KNetwork::KDatagramSocket::bind ( const KResolverEntry &  entry) [inline, virtual]

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.

bool KDatagramSocket::connect ( const TQString &  node = TQString::null,
const TQString &  service = TQString::null 
) [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 ( tqwriteBlock(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.

virtual bool KNetwork::KDatagramSocket::connect ( const KResolverEntry &  entry) [inline, virtual]

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.

KDatagramPacket KDatagramSocket::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.

TQ_LONG KDatagramSocket::send ( const KDatagramPacket &  packet) [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.

TQ_LONG KDatagramSocket::tqwriteBlock ( const char *  data,
TQ_ULONG  len,
const TDESocketAddress &  to 
) [virtual]

Writes data to the socket.

Reimplemented from KClientSocketBase.

Definition at line 173 of file kdatagramsocket.cpp.


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

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.