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

tdecore

  • KNetwork
  • TDESocketAddress
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
KNetwork::TDESocketAddress Class Reference

#include <tdesocketaddress.h>

Inheritance diagram for KNetwork::TDESocketAddress:
KNetwork::KInetSocketAddress KNetwork::KUnixSocketAddress

Public Member Functions

 TDESocketAddress ()
 
 TDESocketAddress (const sockaddr *sa, TQ_UINT16 len)
 
 TDESocketAddress (const TDESocketAddress &other)
 
virtual ~TDESocketAddress ()
 
TDESocketAddress & operator= (const TDESocketAddress &other)
 
const sockaddr * address () const
 
sockaddr * address ()
 
TDESocketAddress & setAddress (const sockaddr *sa, TQ_UINT16 len)
 
 operator const sockaddr * () const
 
TQ_UINT16 length () const
 
TDESocketAddress & setLength (TQ_UINT16 len)
 
int family () const
 
virtual TDESocketAddress & setFamily (int family)
 
int ianaFamily () const
 
bool operator== (const TDESocketAddress &other) const
 
virtual TQString nodeName () const
 
virtual TQString serviceName () const
 
virtual TQString toString () const
 
KInetSocketAddress & asInet ()
 
KInetSocketAddress asInet () const
 
KUnixSocketAddress & asUnix ()
 
KUnixSocketAddress asUnix () const
 

Static Public Member Functions

static int ianaFamily (int af)
 
static int fromIanaFamily (int iana)
 

Protected Member Functions

 TDESocketAddress (TDESocketAddressData *d)
 

Protected Attributes

TDESocketAddressData * d
 

Detailed Description

A generic socket address.

This class holds one generic socket address.

Author
Thiago Macieira thiag.nosp@m.o.ma.nosp@m.cieir.nosp@m.a@kd.nosp@m.email.nosp@m..net

Definition at line 423 of file tdesocketaddress.h.

Constructor & Destructor Documentation

◆ TDESocketAddress() [1/4]

TDESocketAddress::TDESocketAddress ( )

Default constructor.

Creates an empty object

Definition at line 418 of file tdesocketaddress.cpp.

◆ TDESocketAddress() [2/4]

TDESocketAddress::TDESocketAddress ( const sockaddr *  sa,
TQ_UINT16  len 
)

Creates this object with the given data.

The raw socket address is copied into this object.

Parameters
sathe socket address structure
lenthe socket address length

Definition at line 424 of file tdesocketaddress.cpp.

◆ TDESocketAddress() [3/4]

TDESocketAddress::TDESocketAddress ( const TDESocketAddress &  other)

Copy constructor.

This creates a copy of the other object.

Data is not shared.

Parameters
otherthe object to copy from

Definition at line 430 of file tdesocketaddress.cpp.

◆ ~TDESocketAddress()

TDESocketAddress::~TDESocketAddress ( )
virtual

Destructor.

Frees any associated resources.

Definition at line 441 of file tdesocketaddress.cpp.

◆ TDESocketAddress() [4/4]

TDESocketAddress::TDESocketAddress ( TDESocketAddressData *  d)
protected

Definition at line 436 of file tdesocketaddress.cpp.

Member Function Documentation

◆ address() [1/2]

sockaddr * TDESocketAddress::address ( )

Returns the socket address structure, to be passed down to low level functions.

Note that this function returns NULL for invalid or empty sockets, so you may use to to test for validity.

The returned value, if not NULL, is an internal buffer which is guaranteed to be at least length() bytes long.

Definition at line 468 of file tdesocketaddress.cpp.

◆ address() [2/2]

const sockaddr * TDESocketAddress::address ( ) const

Returns the socket address structure, to be passed down to low level functions.

Note that this function returns NULL for invalid or empty sockets, so you may use to to test for validity.

Definition at line 461 of file tdesocketaddress.cpp.

◆ asInet() [1/2]

KInetSocketAddress & TDESocketAddress::asInet ( )

Returns an object reference that can be used to manipulate this socket as an Internet socket address.

Both objects share the same data.

Definition at line 645 of file tdesocketaddress.cpp.

◆ asInet() [2/2]

KInetSocketAddress TDESocketAddress::asInet ( ) const

Returns an object is equal to this object's data, but they don't share it.

Definition at line 650 of file tdesocketaddress.cpp.

◆ asUnix() [1/2]

KUnixSocketAddress & TDESocketAddress::asUnix ( )

Returns an object reference that can be used to manipulate this socket as a Unix socket address.

Both objects share the same data.

Definition at line 655 of file tdesocketaddress.cpp.

◆ asUnix() [2/2]

KUnixSocketAddress TDESocketAddress::asUnix ( ) const

Returns an object is equal to this object's data, but they don't share it.

Definition at line 660 of file tdesocketaddress.cpp.

◆ family()

int TDESocketAddress::family ( ) const

Returns the family of this address.

Returns
the family of this address, AF_UNSPEC if it's undefined

Definition at line 499 of file tdesocketaddress.cpp.

◆ fromIanaFamily()

int TDESocketAddress::fromIanaFamily ( int  iana)
static

Returns the address family of the given IANA family number.

Returns
the address family, AF_UNSPEC for unknown IANA family numbers

Definition at line 686 of file tdesocketaddress.cpp.

◆ ianaFamily() [1/2]

int KNetwork::TDESocketAddress::ianaFamily ( ) const
inline

Returns the IANA family number of this address.

Returns
the IANA family number of this address (1 for AF_INET. 2 for AF_INET6, otherwise 0)

Definition at line 550 of file tdesocketaddress.h.

◆ ianaFamily() [2/2]

int TDESocketAddress::ianaFamily ( int  af)
static

Returns the IANA family number of the given address family.

Returns 0 if there is no corresponding IANA family number.

Parameters
afthe address family, in AF_* constants
Returns
the IANA family number of this address (1 for AF_INET. 2 for AF_INET6, otherwise 0)

Definition at line 665 of file tdesocketaddress.cpp.

◆ length()

TQ_UINT16 TDESocketAddress::length ( ) const

Returns the length of this socket address structure.

Definition at line 485 of file tdesocketaddress.cpp.

◆ nodeName()

TQString TDESocketAddress::nodeName ( ) const
virtual

Returns the node name of this socket.

In the case of Internet sockets, this is string representation of the IP address. The default implementation returns TQString::null.

Returns
the node name, can be TQString::null
Bug:
use KResolver to resolve unknown families

Definition at line 576 of file tdesocketaddress.cpp.

◆ operator const sockaddr *()

KNetwork::TDESocketAddress::operator const sockaddr * ( ) const
inline

Returns the socket address structure, to be passed down to low level functions.

Definition at line 499 of file tdesocketaddress.h.

◆ operator=()

TDESocketAddress & TDESocketAddress::operator= ( const TDESocketAddress &  other)

Performs a shallow copy of the other object into this one.

Data will be copied.

Parameters
otherthe object to copy from

Definition at line 452 of file tdesocketaddress.cpp.

◆ operator==()

bool TDESocketAddress::operator== ( const TDESocketAddress &  other) const

Returns true if this equals the other socket.

Socket addresses are considered matching if and only if all data is the same.

Parameters
otherthe other socket
Returns
true if both sockets are equal

Definition at line 515 of file tdesocketaddress.cpp.

◆ serviceName()

TQString TDESocketAddress::serviceName ( ) const
virtual

Returns the service name for this socket.

In the case of Internet sockets, this is the port number. The default implementation returns TQString::null.

Returns
the service name, can be TQString::null
Bug:
use KResolver to resolve unknown families

Definition at line 603 of file tdesocketaddress.cpp.

◆ setAddress()

TDESocketAddress & TDESocketAddress::setAddress ( const sockaddr *  sa,
TQ_UINT16  len 
)

Sets the address to the given address.

The raw socket address is copied into this object.

Parameters
sathe socket address structure
lenthe socket address length

Definition at line 475 of file tdesocketaddress.cpp.

◆ setFamily()

TDESocketAddress & TDESocketAddress::setFamily ( int  family)
virtual

Sets the family of this object.

Note: setting the family will probably invalidate any address data contained in this object. Use this function with care.

Parameters
familythe new family to set

Definition at line 506 of file tdesocketaddress.cpp.

◆ setLength()

TDESocketAddress & TDESocketAddress::setLength ( TQ_UINT16  len)

Sets the length of this socket structure.

Use this function with care. It allows you to resize the internal buffer to fit needs. This function should not be used except for handling unknown socket address structures.

Also note that this function may invalidate the socket if a known family is set (Internet or Unix socket) and the new length would be too small to hold the system's sockaddr_* structure. If unsure, reset the family:

TDESocketAddress qsa;
[...]
qsa.setFamily(AF_UNSPEC).setLength(newlen);
KNetwork::TDESocketAddress
A generic socket address.
Definition: tdesocketaddress.h:424
KNetwork::TDESocketAddress::setFamily
virtual TDESocketAddress & setFamily(int family)
Sets the family of this object.
Definition: tdesocketaddress.cpp:506
KNetwork::TDESocketAddress::setLength
TDESocketAddress & setLength(TQ_UINT16 len)
Sets the length of this socket structure.
Definition: tdesocketaddress.cpp:492
Parameters
lenthe new length

Definition at line 492 of file tdesocketaddress.cpp.

◆ toString()

TQString TDESocketAddress::toString ( ) const
virtual

Returns this socket address as a string suitable for printing.

Family, node and service are part of this address.

Bug:
use KResolver to resolve unknown families

Definition at line 623 of file tdesocketaddress.cpp.

Member Data Documentation

◆ d

TDESocketAddressData* KNetwork::TDESocketAddress::d
protected

Definition at line 618 of file tdesocketaddress.h.


The documentation for this class was generated from the following files:
  • tdesocketaddress.h
  • tdesocketaddress.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.9.4
This website is maintained by Timothy Pearson.