kdecore Library API Documentation

KSocketAddress Class Reference

A socket address. a socket address. More...

#include <ksockaddr.h>

Inheritance diagram for KSocketAddress:

QObject KInetSocketAddress KUnixSocketAddress List of all members.

Public Member Functions

virtual ~KSocketAddress ()
virtual QString pretty () const
const sockaddr * address () const
virtual ksocklen_t size () const
 operator const sockaddr * () const
int family () const
int ianaFamily () const
virtual bool isEqual (const KSocketAddress &other) const
bool isEqual (const KSocketAddress *other) const
bool operator== (const KSocketAddress &other) const
bool isCoreEqual (const KSocketAddress &other) const
bool isCoreEqual (const KSocketAddress *other) const
virtual QString nodeName () const
virtual QString serviceName () const

Static Public Member Functions

KSocketAddressnewAddress (const struct sockaddr *sa, ksocklen_t size)
int ianaFamily (int af)
int fromIanaFamily (int iana)

Protected Member Functions

 KSocketAddress ()
 KSocketAddress (const sockaddr *sa, ksocklen_t size)
virtual void virtual_hook (int id, void *data)

Protected Attributes

sockaddr * data
ksocklen_t datasize
bool owndata

Friends

class KExtendedSocket

Detailed Description

A socket address. a socket address.

This class envelopes almost if not all socket addresses.

Author:
Thiago Macieira <thiago.macieira@kdemail.net>

Definition at line 45 of file ksockaddr.h.


Constructor & Destructor Documentation

KSocketAddress::KSocketAddress  )  [inline, protected]
 

Creates an empty class.

Definition at line 52 of file ksockaddr.h.

Referenced by newAddress().

KSocketAddress::KSocketAddress const sockaddr *  sa,
ksocklen_t  size
[protected]
 

Creates with given data.

Parameters:
sa a sockaddr structure
size the size of sa

Definition at line 81 of file ksockaddr.cpp.

KSocketAddress::~KSocketAddress  )  [virtual]
 

Destructor.

Definition at line 102 of file ksockaddr.cpp.


Member Function Documentation

QString KSocketAddress::pretty  )  const [virtual]
 

Returns a string representation of this socket.

Returns:
a pretty string representation

Reimplemented in KInetSocketAddress, and KUnixSocketAddress.

Definition at line 108 of file ksockaddr.cpp.

const sockaddr* KSocketAddress::address  )  const [inline]
 

Returns a sockaddr structure, for passing down to library functions.

Returns:
the sockaddr structure, can be 0

Reimplemented in KUnixSocketAddress.

Definition at line 77 of file ksockaddr.h.

Referenced by KInetSocketAddress::areEqualInet(), KInetSocketAddress::areEqualInet6(), KUnixSocketAddress::areEqualUnix(), KNetwork::KInetSocketAddress::operator const sockaddr_in *(), KNetwork::KInetSocketAddress::operator const sockaddr_in6 *(), and KServerSocket::port().

virtual ksocklen_t KSocketAddress::size  )  const [inline, virtual]
 

Returns sockaddr structure size.

Returns:
the size of the sockaddr structre, 0 if there is none.

Reimplemented in KInetSocketAddress.

Definition at line 84 of file ksockaddr.h.

Referenced by KInetSocketAddress::areEqualInet(), KInetSocketAddress::areEqualInet6(), and KUnixSocketAddress::areEqualUnix().

KSocketAddress::operator const sockaddr *  )  const [inline]
 

Returns a sockaddr structure, for passing down to library functions.

Returns:
the sockaddr structure, can be 0.
See also:
address()

Definition at line 92 of file ksockaddr.h.

int KSocketAddress::family  )  const
 

Returns the family of this address.

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

Definition at line 113 of file ksockaddr.cpp.

Referenced by KInetSocketAddress::areEqualInet(), KInetSocketAddress::areEqualInet6(), KUnixSocketAddress::areEqualUnix(), ianaFamily(), isCoreEqual(), isEqual(), and KInetSocketAddress::setAddress().

int KSocketAddress::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 106 of file ksockaddr.h.

References family().

bool KSocketAddress::isEqual const KSocketAddress other  )  const [virtual]
 

Returns true if this equals the other socket.

Parameters:
other the other socket
Returns:
true if both sockets are equal

Definition at line 157 of file ksockaddr.cpp.

References KInetSocketAddress::areEqualInet(), KInetSocketAddress::areEqualInet6(), KUnixSocketAddress::areEqualUnix(), data, datasize, and family().

Referenced by operator==().

bool KSocketAddress::operator== const KSocketAddress other  )  const [inline]
 

Overloaded == operator.

See also:
isEqual()

Definition at line 122 of file ksockaddr.h.

References isEqual().

bool KSocketAddress::isCoreEqual const KSocketAddress other  )  const
 

Some sockets may differ in such things as services or port numbers, like Internet sockets.

This function compares only the core part of that, if possible.

If not possible, like the default implementation, this returns the same as isEqual.

Parameters:
other the other socket
Returns:
true if the code part is equal

Definition at line 177 of file ksockaddr.cpp.

References KInetSocketAddress::areEqualInet(), KInetSocketAddress::areEqualInet6(), KUnixSocketAddress::areEqualUnix(), and family().

Referenced by isCoreEqual().

bool KSocketAddress::isCoreEqual const KSocketAddress other  )  const [inline]
 

Some sockets may differ in such things as services or port numbers, like Internet sockets.

This function compares only the core part of that, if possible.

If not possible, like the default implementation, this returns the same as isEqual.

Parameters:
other the other socket
Returns:
true if the code part is equal

Definition at line 147 of file ksockaddr.h.

References isCoreEqual().

QString KSocketAddress::nodeName  )  const [virtual]
 

Returns the node name of this socket, as KExtendedSocket::lookup expects as the first argument.

In the case of Internet sockets, this is the hostname. The default implementation returns QString::null.

Returns:
the node name, can be QString::null

Reimplemented in KInetSocketAddress.

Definition at line 194 of file ksockaddr.cpp.

QString KSocketAddress::serviceName  )  const [virtual]
 

Returns the service name for this socket, as KExtendedSocket::lookup expects as the service argument.

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

Returns:
the service name, can be QString::null

Reimplemented in KInetSocketAddress, and KUnixSocketAddress.

Definition at line 199 of file ksockaddr.cpp.

KSocketAddress * KSocketAddress::newAddress const struct sockaddr *  sa,
ksocklen_t  size
[static]
 

Creates a new KSocketAddress or descendant class from given raw socket address.

Parameters:
sa new socket address
size new socket address's length
Returns:
the new KSocketAddress, or 0 if the function failed

Definition at line 121 of file ksockaddr.cpp.

References KSocketAddress().

int KSocketAddress::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:
af the 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 204 of file ksockaddr.cpp.

int KSocketAddress::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 219 of file ksockaddr.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Feb 18 15:10:05 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003