\section{KNetwork::KSocket\-Address Class Reference}
\label{classKNetwork_1_1KSocketAddress}\index{KNetwork::KSocketAddress@{KNetwork::KSocketAddress}}
A generic socket address.  


{\tt \#include $<$ksocketaddress.h$>$}

Inheritance diagram for KNetwork::KSocket\-Address:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=183pt]{classKNetwork_1_1KSocketAddress__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KSocket\-Address} ()
\item 
{\bf KSocket\-Address} (const sockaddr $\ast$sa, Q\_\-UINT16 len)
\item 
{\bf KSocket\-Address} (const {\bf KSocket\-Address} \&other)
\item 
virtual {\bf $\sim$KSocket\-Address} ()
\item 
{\bf KSocket\-Address} \& {\bf operator=} (const {\bf KSocket\-Address} \&other)
\item 
const sockaddr $\ast$ {\bf address} () const 
\item 
sockaddr $\ast$ {\bf address} ()
\item 
{\bf KSocket\-Address} \& {\bf set\-Address} (const sockaddr $\ast$sa, Q\_\-UINT16 len)
\item 
{\bf operator const sockaddr $\ast$} () const 
\item 
Q\_\-UINT16 {\bf length} () const 
\item 
{\bf KSocket\-Address} \& {\bf set\-Length} (Q\_\-UINT16 len)
\item 
int {\bf family} () const 
\item 
virtual {\bf KSocket\-Address} \& {\bf set\-Family} (int family)
\item 
int {\bf iana\-Family} () const 
\item 
bool {\bf operator==} (const {\bf KSocket\-Address} \&other) const 
\item 
virtual {\bf QString} {\bf node\-Name} () const 
\item 
virtual {\bf QString} {\bf service\-Name} () const 
\item 
virtual {\bf QString} {\bf to\-String} () const 
\item 
{\bf KInet\-Socket\-Address} \& {\bf as\-Inet} ()
\item 
{\bf KInet\-Socket\-Address} {\bf as\-Inet} () const 
\item 
{\bf KUnix\-Socket\-Address} \& {\bf as\-Unix} ()
\item 
{\bf KUnix\-Socket\-Address} {\bf as\-Unix} () const 
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static int {\bf iana\-Family} (int af)
\item 
static int {\bf from\-Iana\-Family} (int iana)
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
{\bf KSocket\-Address} (KSocket\-Address\-Data $\ast$d)\label{classKNetwork_1_1KSocketAddress_b0}

\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
KSocket\-Address\-Data $\ast$ {\bf d}\label{classKNetwork_1_1KSocketAddress_p0}

\end{CompactItemize}


\subsection{Detailed Description}
A generic socket address. 

This class holds one generic socket address.

\begin{Desc}
\item[Author:]Thiago Macieira $<${\tt thiago.macieira@kdemail.net}$>$ \end{Desc}




Definition at line 413 of file ksocketaddress.h.

\subsection{Constructor \& Destructor Documentation}
\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!KSocketAddress@{KSocketAddress}}
\index{KSocketAddress@{KSocketAddress}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket\-Address::KSocket\-Address ()}\label{classKNetwork_1_1KSocketAddress_a0}


Default constructor. 

Creates an empty object 

Definition at line 401 of file ksocketaddress.cpp.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!KSocketAddress@{KSocketAddress}}
\index{KSocketAddress@{KSocketAddress}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket\-Address::KSocket\-Address (const sockaddr $\ast$ {\em sa}, Q\_\-UINT16 {\em len})}\label{classKNetwork_1_1KSocketAddress_a1}


Creates this object with the given data. 

The raw socket address is copied into this object.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em sa}]the socket address structure \item[{\em len}]the socket address length \end{description}
\end{Desc}


Definition at line 407 of file ksocketaddress.cpp.

References set\-Address().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!KSocketAddress@{KSocketAddress}}
\index{KSocketAddress@{KSocketAddress}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket\-Address::KSocket\-Address (const {\bf KSocket\-Address} \& {\em other})}\label{classKNetwork_1_1KSocketAddress_a2}


Copy constructor. 

This creates a copy of the other object.

Data is not shared.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em other}]the object to copy from \end{description}
\end{Desc}


Definition at line 413 of file ksocketaddress.cpp.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!~KSocketAddress@{$\sim$KSocketAddress}}
\index{~KSocketAddress@{$\sim$KSocketAddress}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket\-Address::$\sim${\bf KSocket\-Address} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketAddress_a3}


Destructor. 

Frees any associated resources. 

Definition at line 424 of file ksocketaddress.cpp.

\subsection{Member Function Documentation}
\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!operator=@{operator=}}
\index{operator=@{operator=}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KSocket\-Address} \& KSocket\-Address::operator= (const {\bf KSocket\-Address} \& {\em other})}\label{classKNetwork_1_1KSocketAddress_a4}


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

Data will be copied.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em other}]the object to copy from \end{description}
\end{Desc}


Definition at line 435 of file ksocketaddress.cpp.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!address@{address}}
\index{address@{address}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const sockaddr $\ast$ KSocket\-Address::address () const}\label{classKNetwork_1_1KSocketAddress_a5}


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 444 of file ksocketaddress.cpp.

Referenced by KNetwork::KSocket\-Device::disconnect(), KNetwork::KSocks\-Socket\-Device::local\-Address(), KNetwork::KSocket\-Device::local\-Address(), KNetwork::KSocks\-Socket\-Device::peer\-Address(), and KNetwork::KSocket\-Device::peer\-Address().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!address@{address}}
\index{address@{address}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}sockaddr $\ast$ KSocket\-Address::address ()}\label{classKNetwork_1_1KSocketAddress_a6}


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 {\bf length()}{\rm (p.\,\pageref{classKNetwork_1_1KSocketAddress_a9})} bytes long. 

Definition at line 451 of file ksocketaddress.cpp.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!setAddress@{setAddress}}
\index{setAddress@{setAddress}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KSocket\-Address} \& KSocket\-Address::set\-Address (const sockaddr $\ast$ {\em sa}, Q\_\-UINT16 {\em len})}\label{classKNetwork_1_1KSocketAddress_a7}


Sets the address to the given address. 

The raw socket address is copied into this object.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em sa}]the socket address structure \item[{\em len}]the socket address length \end{description}
\end{Desc}


Definition at line 458 of file ksocketaddress.cpp.

Referenced by KSocket\-Address().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!operator const sockaddr *@{operator const sockaddr $\ast$}}
\index{operator const sockaddr *@{operator const sockaddr $\ast$}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KNetwork::KSocket\-Address::operator const sockaddr $\ast$ () const\hspace{0.3cm}{\tt  [inline]}}\label{classKNetwork_1_1KSocketAddress_a8}


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



Definition at line 489 of file ksocketaddress.h.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!length@{length}}
\index{length@{length}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Q\_\-UINT16 KSocket\-Address::length () const}\label{classKNetwork_1_1KSocketAddress_a9}


Returns the length of this socket address structure. 



Definition at line 468 of file ksocketaddress.cpp.

Referenced by KNetwork::KSocket\-Device::disconnect(), KNetwork::KSocks\-Socket\-Device::local\-Address(), KNetwork::KSocket\-Device::local\-Address(), KNetwork::KSocks\-Socket\-Device::peer\-Address(), and KNetwork::KSocket\-Device::peer\-Address().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!setLength@{setLength}}
\index{setLength@{setLength}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KSocket\-Address} \& KSocket\-Address::set\-Length (Q\_\-UINT16 {\em len})}\label{classKNetwork_1_1KSocketAddress_a10}


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\_\-$\ast$ structure. If unsure, reset the family:



\footnotesize\begin{verbatim}   KSocketAddress qsa;
   [...]
   qsa.setFamily(AF_UNSPEC).setLength(newlen);
\end{verbatim}
\normalsize


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em len}]the new length \end{description}
\end{Desc}


Definition at line 475 of file ksocketaddress.cpp.

Referenced by KNetwork::KSocks\-Socket\-Device::local\-Address(), KNetwork::KSocket\-Device::local\-Address(), KNetwork::KSocks\-Socket\-Device::peer\-Address(), and KNetwork::KSocket\-Device::peer\-Address().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!family@{family}}
\index{family@{family}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KSocket\-Address::family () const}\label{classKNetwork_1_1KSocketAddress_a11}


Returns the family of this address. 

\begin{Desc}
\item[Returns:]the family of this address, AF\_\-UNSPEC if it's undefined \end{Desc}


Definition at line 482 of file ksocketaddress.cpp.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!setFamily@{setFamily}}
\index{setFamily@{setFamily}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KSocket\-Address} \& KSocket\-Address::set\-Family (int {\em family})\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketAddress_a12}


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.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em family}]the new family to set \end{description}
\end{Desc}


Definition at line 489 of file ksocketaddress.cpp.

Referenced by KNetwork::KSocket\-Device::disconnect().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!ianaFamily@{ianaFamily}}
\index{ianaFamily@{ianaFamily}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KNetwork::KSocket\-Address::iana\-Family () const\hspace{0.3cm}{\tt  [inline]}}\label{classKNetwork_1_1KSocketAddress_a13}


Returns the IANA family number of this address. 

\begin{Desc}
\item[Returns:]the IANA family number of this address (1 for AF\_\-INET. 2 for AF\_\-INET6, otherwise 0) \end{Desc}


Definition at line 540 of file ksocketaddress.h.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!operator==@{operator==}}
\index{operator==@{operator==}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Address::operator== (const {\bf KSocket\-Address} \& {\em other}) const}\label{classKNetwork_1_1KSocketAddress_a14}


Returns true if this equals the other socket. 

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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em other}]the other socket \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if both sockets are equal \end{Desc}


Definition at line 498 of file ksocketaddress.cpp.

References d.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!nodeName@{nodeName}}
\index{nodeName@{nodeName}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KSocket\-Address::node\-Name () const\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketAddress_a15}


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 QString::null.

\begin{Desc}
\item[Returns:]the node name, can be QString::null \end{Desc}
\begin{Desc}
\item[{\bf Bug}]use {\bf KResolver}{\rm (p.\,\pageref{classKNetwork_1_1KResolver})} to resolve unknown families \end{Desc}


Definition at line 555 of file ksocketaddress.cpp.

References QString::number(), QString::ref(), and QString::truncate().

Referenced by to\-String().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!serviceName@{serviceName}}
\index{serviceName@{serviceName}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KSocket\-Address::service\-Name () const\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketAddress_a16}


Returns the service name for this socket. 

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

\begin{Desc}
\item[Returns:]the service name, can be QString::null \end{Desc}
\begin{Desc}
\item[{\bf Bug}]use {\bf KResolver}{\rm (p.\,\pageref{classKNetwork_1_1KResolver})} to resolve unknown families \end{Desc}


Definition at line 581 of file ksocketaddress.cpp.

References QString::number(), and QString::ref().

Referenced by to\-String().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!toString@{toString}}
\index{toString@{toString}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KSocket\-Address::to\-String () const\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketAddress_a17}


Returns this socket address as a string suitable for printing. 

Family, node and service are part of this address.

\begin{Desc}
\item[{\bf Bug}]use {\bf KResolver}{\rm (p.\,\pageref{classKNetwork_1_1KResolver})} to resolve unknown families \end{Desc}


Definition at line 601 of file ksocketaddress.cpp.

References QString::arg(), QString::from\-Latin1(), node\-Name(), service\-Name(), and QObject::tr().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!asInet@{asInet}}
\index{asInet@{asInet}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KInet\-Socket\-Address} \& KSocket\-Address::as\-Inet ()}\label{classKNetwork_1_1KSocketAddress_a18}


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 622 of file ksocketaddress.cpp.

References QString::ref().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!asInet@{asInet}}
\index{asInet@{asInet}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KInet\-Socket\-Address} KSocket\-Address::as\-Inet () const}\label{classKNetwork_1_1KSocketAddress_a19}


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



Definition at line 627 of file ksocketaddress.cpp.

References QString::ref().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!asUnix@{asUnix}}
\index{asUnix@{asUnix}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KUnix\-Socket\-Address} \& KSocket\-Address::as\-Unix ()}\label{classKNetwork_1_1KSocketAddress_a20}


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 632 of file ksocketaddress.cpp.

References QString::ref().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!asUnix@{asUnix}}
\index{asUnix@{asUnix}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KUnix\-Socket\-Address} KSocket\-Address::as\-Unix () const}\label{classKNetwork_1_1KSocketAddress_a21}


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



Definition at line 637 of file ksocketaddress.cpp.

References QString::ref().\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!ianaFamily@{ianaFamily}}
\index{ianaFamily@{ianaFamily}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KSocket\-Address::iana\-Family (int {\em af})\hspace{0.3cm}{\tt  [static]}}\label{classKNetwork_1_1KSocketAddress_e0}


Returns the IANA family number of the given address family. 

Returns 0 if there is no corresponding IANA family number. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em af}]the address family, in AF\_\-$\ast$ constants \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]the IANA family number of this address (1 for AF\_\-INET. 2 for AF\_\-INET6, otherwise 0) \end{Desc}


Definition at line 642 of file ksocketaddress.cpp.\index{KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}!fromIanaFamily@{fromIanaFamily}}
\index{fromIanaFamily@{fromIanaFamily}!KNetwork::KSocketAddress@{KNetwork::KSocket\-Address}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KSocket\-Address::from\-Iana\-Family (int {\em iana})\hspace{0.3cm}{\tt  [static]}}\label{classKNetwork_1_1KSocketAddress_e1}


Returns the address family of the given IANA family number. 

\begin{Desc}
\item[Returns:]the address family, AF\_\-UNSPEC for unknown IANA family numbers \end{Desc}


Definition at line 659 of file ksocketaddress.cpp.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
ksocketaddress.h\item 
ksocketaddress.cpp\end{CompactItemize}
