class KInetSocketAddress

# class KInetSocketAddress | an Internet socket address. More...
Definition | `#include <ksockaddr.h>`
Inherits | KSocketAddress [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- KInetSocketAddress ()
- KInetSocketAddress (const KInetSocketAddress&)
- KInetSocketAddress (const sockaddr_in* sin, ksocklen_t len)
- KInetSocketAddress (const sockaddr_in6* sin6, ksocklen_t len)
- KInetSocketAddress (const in_addr& addr, unsigned short port)
- KInetSocketAddress (const in6_addr& addr, unsigned short port)
- KInetSocketAddress (const QString& addr, unsigned short port, int family = -1)
- virtual ~KInetSocketAddress ()
- bool setAddress (const KInetSocketAddress& ksa)
- bool setAddress (const sockaddr_in* sin, ksocklen_t len)
- bool setAddress (const sockaddr_in6* sin6, ksocklen_t len)
- bool setAddress (const in_addr& addr, unsigned short port)
- bool setAddress (const in6_addr& addr, unsigned short port)
- bool setAddress (const QString& addr, unsigned short port, int family = -1)
- bool setHost (const in_addr& addr)
- bool setHost (const in6_addr& addr)
- bool setHost (const QString& addr, int family = -1)
- bool setPort (unsigned short port)
- bool setFamily (int family)
- bool setFlowinfo (Q_UINT32 flowinfo)
- bool setScopeId (int scopeid)
- virtual QString pretty () const
- virtual QString nodeName () const
- virtual QString serviceName () const
- const sockaddr_in* addressV4 () const
- const sockaddr_in6* addressV6 () const
- in_addr hostV4 () const
- in6_addr hostV6 () const
- unsigned short port () const
- Q_UINT32 flowinfo () const
- int scopeId () const
- virtual ksocklen_t size () const
- operator const sockaddr_in* () const
- operator const sockaddr_in6* () const
- KInetSocketAddress& operator= (const KInetSocketAddress &other)

#### Public Static Methods

- static bool areEqualInet (const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly)
- static bool areEqualInet6 (const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly)
- static QString addrToString (int family, const void *addr)
- static bool stringToAddr (int family, const char *text, void *dest)

#### Public Members

- friend class KExtendedSocket

#### Protected Methods

- virtual void virtual_hook ( int id, void* data )

## Detailed Description

An Inet (IPv4 or IPv6) socket address

This is an IPv4 or IPv6 address of the Internet

This class inherits most of the functionality from KSocketAddress, but is targeted specifically to Internet addresses

KInetSocketAddress () | ### KInetSocketAddress

Default constructor. Does nothing

KInetSocketAddress (const KInetSocketAddress&) | ### KInetSocketAddress

Copy constructor

KInetSocketAddress (const sockaddr_in* sin, ksocklen_t len) | ### KInetSocketAddress

Creates an IPv4 socket from raw sockaddr_in.

Parameters:

sin | a sockaddr_in structure to copy from
len | the socket address length

KInetSocketAddress (const sockaddr_in6* sin6, ksocklen_t len) | ### KInetSocketAddress

Creates an IPv6 socket from raw sockaddr_in6.

Parameters:

sin6 | a sockaddr_in6 structure to copy from
len | the socket address length

KInetSocketAddress (const in_addr& addr, unsigned short port) | ### KInetSocketAddress

Creates a socket from information.

Parameters:

addr | a binary address
port | a port number

KInetSocketAddress (const in6_addr& addr, unsigned short port) | ### KInetSocketAddress

Creates a socket from information.

Parameters:

addr | a binary address
port | a port number

KInetSocketAddress (const QString& addr, unsigned short port, int family = -1) | ### KInetSocketAddress

Creates a socket from text representation.

Parameters:

addr | a text representation of the address
port | a port number
family | the family for this address. Use -1 to guess the family type

See also: setAddress

~KInetSocketAddress () | ### ~KInetSocketAddress

[virtual]

Destructor

bool setAddress (const KInetSocketAddress& ksa) | ### setAddress

Sets this socket to given socket.

Parameters:

ksa | the other socket

Returns: true if successful, false otherwise

bool setAddress (const sockaddr_in* sin, ksocklen_t len) | ### setAddress

Sets this socket to given raw socket.

Parameters:

sin | the raw socket
len | the socket address length

Returns: true if successful, false otherwise

bool setAddress (const sockaddr_in6* sin6, ksocklen_t len) | ### setAddress

Sets this socket to given raw socket.

Note: this function does not clear the scope ID and flow info values

Parameters:

sin6 | the raw socket
len | the socket address length

Returns: true if successful, false otherwise

bool setAddress (const in_addr& addr, unsigned short port) | ### setAddress

Sets this socket to raw address and port.

Parameters:

addr | the address
port | the port number

Returns: true if successful, false otherwise

bool setAddress (const in6_addr& addr, unsigned short port) | ### setAddress

Sets this socket to raw address and port.

Parameters:

addr | the address
port | the port number

Returns: true if successful, false otherwise

bool setAddress (const QString& addr, unsigned short port, int family = -1) | ### setAddress

Sets this socket to text address and port

You can use the `family` parameter to specify what kind of socket you want this to be. It could be AF_INET or AF_INET6 or -1.

If the value is -1 (default), this function will make an effort to discover what is the family. That isn't too hard, actually, and it works in all cases. But, if you want to be sure that your socket is of the type you want, use this parameter.

This function returns false if the socket address was not valid.

Parameters:

addr | the address
port | the port number
family | the address family, -1 for any

Returns: true if successful, false otherwise

bool setHost (const in_addr& addr) | ### setHost

Sets this socket's host address to given raw address.

Parameters:

addr | the address

Returns: true if successful, false otherwise

bool setHost (const in6_addr& addr) | ### setHost

Sets this socket's host address to given raw address.

Parameters:

addr | the address

Returns: true if successful, false otherwise

bool setHost (const QString& addr, int family = -1) | ### setHost

Sets this socket's host address to given text representation.

Parameters:

addr | the address
family | the address family, -1 to guess the family

Returns: true if successful, false otherwise

bool setPort (unsigned short port) | ### setPort

Sets this socket's port number to given port number.

Parameters:

port | the port number

Returns: true if successful, false otherwise

bool setFamily (int family) | ### setFamily

Turns this into an IPv4 or IPv6 address.

Parameters:

family | the new address family

Returns: false if this is v6 and information was lost. That doesn't mean the conversion was unsuccessful.

bool setFlowinfo (Q_UINT32 flowinfo) | ### setFlowinfo

Sets flowinfo information for this socket address if this is IPv6.

Parameters:

flowinfo | flowinfo

Returns: true if successful, false otherwise

bool setScopeId (int scopeid) | ### setScopeId

Sets the scope id for this socket if this is IPv6.

Parameters:

scopeid | the scope id

Returns: true if successful, false otherwise

QString pretty () | ### pretty

[const virtual]

Returns a pretty representation of this address.

Returns: a pretty representation

Reimplemented from KSocketAddress.

QString nodeName () | ### nodeName

[const virtual]

Returns the text representation of the host address.

Returns: a text representation of the host address

Reimplemented from KSocketAddress.

QString serviceName () | ### serviceName

[const virtual]

Returns the text representation of the port number.

Parameters:

the | name of the service (a number)

Reimplemented from KSocketAddress.

const sockaddr_in* addressV4 () | ### addressV4

[const]

Returns the socket address.

This will be NULL if this is a non-convertible v6. This function will return an IPv4 socket if this IPv6 socket is a v4-mapped address. That is, if it's really an IPv4 address, but in v6 disguise.

Returns: the sockaddr_in struct, can be 0.

const sockaddr_in6* addressV6 () | ### addressV6

[const]

Returns the socket address in IPv6

Returns: the sockaddr_in struct, can be 0 if IPv6 is unsupported.

in_addr hostV4 () | ### hostV4

[const]

Returns the host address. Might be empty.

Returns: the host address

in6_addr hostV6 () | ### hostV6

[const]

Returns the host address.

WARNING: this function is not defined if there is no IPv6 support

Returns: the host address

unsigned short port () | ### port

[const]

Returns the port number.

Returns: the port number

Q_UINT32 flowinfo () | ### flowinfo

[const]

Returns flowinfo for IPv6 socket.

Returns: the flowinfo, 0 if unsupported

int scopeId () | ### scopeId

[const]

Returns the scope id for this IPv6 socket.

Returns: the scope id

ksocklen_t size () | ### size

[const virtual]

Returns the socket length. Will be either sizeof(sockaddr_in) or sizeof(sockaddr_in6)

Returns: the length of the socket

Reimplemented from KSocketAddress.

bool areEqualInet (const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly) | ### areEqualInet

[static]

Compares two IPv4 addresses.

Parameters:

s1 | the first address to compare
s2 | the second address to compare
coreOnly | true if only core parts should be compared (only the address)

Returns: true if the given addresses are equal.

See also: areEqualInet6(), KSocketAddress::isEqual(), KSocketAddress::isCoreEqual()

bool areEqualInet6 (const KSocketAddress &s1, const KSocketAddress &s2, bool coreOnly) | ### areEqualInet6

[static]

Compares two IPv6 addresses.

Parameters:

s1 | the first address to compare
s2 | the second address to compare
coreOnly | true if only core parts should be compared (only the address)

Returns: true if the given addresses are equal.

See also: areEqualInet(), KSocketAddress::isEqual(), KSocketAddress::isCoreEqual()

operator const sockaddr_in* () | ### operator const sockaddr_in*

[const]

Returns the socket address. This will be NULL if this is a non-convertible v6.

Returns: the sockaddr_in structure, can be 0 if v6.

See also: addressV4()

operator const sockaddr_in6* () | ### operator const sockaddr_in6*

[const]

Returns the socket address.

Returns: the sockaddr_in structure, can be 0 if v6 is unsupported.

See also: addressV6()

KInetSocketAddress& operator= (const KInetSocketAddress &other) | ### operator=

Sets this object to be the same as the other.

Reimplemented from KSocketAddress.

QString addrToString (int family, const void *addr) | ### addrToString

[static]

Convert s the given raw address into text form. This function returns QString::null if the address cannot be converted.

Parameters:

family | the family of the address
addr | the address, in raw form

Returns: the converted address, or QString::null if not possible.

bool stringToAddr (int family, const char *text, void *dest) | ### stringToAddr

[static]

Converts the address given in text form into raw form. The size of the destination buffer `dest` is supposed to be large enough to hold the address of the given family.

Parameters:

family | the family of the address
text | the text representation of the address
dest | the destination buffer of the address

Returns: true if convertion was successful.

friend class KExtendedSocket | ### KExtendedSocket

void virtual_hook ( int id, void* data ) | ### virtual_hook

[protected virtual]

Reimplemented from KSocketAddress.

- Version: $Id: ksockaddr.h,v 1.15 2002/09/09 21:11:35 tjansen Exp $
- Author: Thiago Macieira
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:15 2003, using kdoc 2.0a54.