\section{KNetwork::KSocket\-Base Class Reference}
\label{classKNetwork_1_1KSocketBase}\index{KNetwork::KSocketBase@{KNetwork::KSocketBase}}
Basic socket functionality.  


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

Inheritance diagram for KNetwork::KSocket\-Base:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=243pt]{classKNetwork_1_1KSocketBase__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{CompactItemize}
\item 
enum {\bf Socket\-Options} \{ \par
{\bf Blocking} =  0x01, 
{\bf Address\-Reuseable} =  0x02, 
{\bf IPv6Only} =  0x04, 
{\bf Keepalive} =  0x08, 
\par
{\bf Broadcast} =  0x10
 \}
\item 
enum {\bf Socket\-Error} \{ \par
{\bf No\-Error} =  0, 
{\bf Lookup\-Failure}, 
{\bf Address\-In\-Use}, 
{\bf Already\-Created}, 
\par
{\bf Already\-Bound}, 
{\bf Already\-Connected}, 
{\bf Not\-Connected}, 
{\bf Not\-Bound}, 
\par
{\bf Not\-Created}, 
{\bf Would\-Block}, 
{\bf Connection\-Refused}, 
{\bf Connection\-Timed\-Out}, 
\par
{\bf In\-Progress}, 
{\bf Net\-Failure}, 
{\bf Not\-Supported}, 
{\bf Timeout}, 
\par
{\bf Unknown\-Error}, 
{\bf Remotely\-Disconnected}
 \}
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KSocket\-Base} ()
\item 
virtual {\bf $\sim$KSocket\-Base} ()
\item 
virtual bool {\bf set\-Blocking} (bool enable)
\item 
bool {\bf blocking} () const 
\item 
virtual bool {\bf set\-Address\-Reuseable} (bool enable)
\item 
bool {\bf address\-Reuseable} () const 
\item 
virtual bool {\bf set\-IPv6Only} (bool enable)
\item 
bool {\bf is\-IPv6Only} () const 
\item 
virtual bool {\bf set\-Broadcast} (bool enable)
\item 
bool {\bf broadcast} () const 
\item 
{\bf KSocket\-Device} $\ast$ {\bf socket\-Device} () const 
\item 
virtual void {\bf set\-Socket\-Device} ({\bf KSocket\-Device} $\ast$device)
\item 
int {\bf set\-Requested\-Capabilities} (int add, int remove=0)
\item 
{\bf Socket\-Error} {\bf error} () const 
\item 
{\bf QString} {\bf error\-String} () const 
\item 
{\bf QMutex} $\ast$ {\bf mutex} () const 
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static {\bf QString} {\bf error\-String} ({\bf Socket\-Error} code)
\item 
static bool {\bf is\-Fatal\-Error} (int code)
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual bool {\bf set\-Socket\-Options} (int opts)
\item 
virtual int {\bf socket\-Options} () const 
\item 
bool {\bf has\-Device} () const 
\item 
void {\bf set\-Error} ({\bf Socket\-Error} error)
\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf KSocket\-Device}\label{classKNetwork_1_1KSocketBase_n0}

\end{CompactItemize}


\subsection{Detailed Description}
Basic socket functionality. 

This class provides the basic socket functionlity for descended classes. Socket classes are thread-safe and provide a recursive mutex should it be needed.

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




Definition at line 97 of file ksocketbase.h.

\subsection{Member Enumeration Documentation}
\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!SocketOptions@{SocketOptions}}
\index{SocketOptions@{SocketOptions}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}enum {\bf KNetwork::KSocket\-Base::Socket\-Options}}\label{classKNetwork_1_1KSocketBase_w23}


Possible socket options. 

These are the options that may be set on a socket:\begin{itemize}
\item Blocking: whether the socket shall operate in blocking or non-blocking mode. This flag defaults to on. See {\bf set\-Blocking}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a2})}.\item Address\-Reusable: whether the address used by this socket will be available for reuse by other sockets. This flag defaults to off. See {\bf set\-Address\-Reuseable}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a4})}.\item IPv6Only: whether an IPv6 socket will accept IPv4 connections through a mapped address. This flag defaults to off. See {\bf set\-IPv6Only}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a6})}.\item Keep\-Alive: whether TCP should send keepalive probes when a connection has gone idle for far too long.\item Broadcast: whether this socket is allowed to send broadcast packets and will receive packets sent to broadcast. \end{itemize}


Definition at line 118 of file ksocketbase.h.\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!SocketError@{SocketError}}
\index{SocketError@{SocketError}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}enum {\bf KNetwork::KSocket\-Base::Socket\-Error}}\label{classKNetwork_1_1KSocketBase_w24}


Possible socket error codes. 

This is a list of possible error conditions that socket classes may be expected to find.

\begin{itemize}
\item No\-Error: no error has been detected\item Lookup\-Failure: if a name lookup has failed\item Address\-In\-Use: address is already in use\item Already\-Bound: cannot bind again\item Already\-Created: cannot recreate the socket\item Not\-Bound: operation required socket to be bound and it isn't\item Not\-Created: operation required socket to exist and it doesn't\item Would\-Block: requested I/O operation would block\item Connection\-Refused: connection actively refused\item Connection\-Timed\-Out: connection timed out\item In\-Progress: operation (connection) is already in progress\item Net\-Failure: a network failure occurred (no route, host down, host unreachable or similar)\item Not\-Supported: requested operation is not supported\item Timeout: a timed operation timed out\item Unknown\-Error: an unknown/unexpected error has happened\item Remotely\-Disconnected: when a connection is disconnected by the other end (since 3.4)\end{itemize}


\begin{Desc}
\item[See also:]{\bf error}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a13})}, {\bf error\-String}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a14})} \end{Desc}


Definition at line 152 of file ksocketbase.h.

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


Default constructor. 



Definition at line 50 of file ksocketbase.cpp.\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!~KSocketBase@{$\sim$KSocketBase}}
\index{~KSocketBase@{$\sim$KSocketBase}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket\-Base::$\sim${\bf KSocket\-Base} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketBase_a1}


Destructor. 



Definition at line 59 of file ksocketbase.cpp.

\subsection{Member Function Documentation}
\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setSocketOptions@{setSocketOptions}}
\index{setSocketOptions@{setSocketOptions}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::set\-Socket\-Options (int {\em opts})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKNetwork_1_1KSocketBase_b0}


Set the given socket options. 

The default implementation does nothing but store the mask internally. Descended classes must override this function to achieve functionality and must also call this implementation.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em opts}]a mask of {\bf Socket\-Options}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_w23})} or-ed bits of options to set or unset \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true on success \end{Desc}
\begin{Desc}
\item[Note:]this function sets the options corresponding to the bits enabled in {\tt opts} but will also unset the optiosn corresponding to the bits not set. \end{Desc}


Reimplemented in {\bf KNetwork::KBuffered\-Socket} {\rm (p.\,\pageref{classKNetwork_1_1KBufferedSocket_b0})}, {\bf KNetwork::KClient\-Socket\-Base} {\rm (p.\,\pageref{classKNetwork_1_1KClientSocketBase_b0})}, {\bf KNetwork::KServer\-Socket} {\rm (p.\,\pageref{classKNetwork_1_1KServerSocket_b0})}, and {\bf KNetwork::KSocket\-Device} {\rm (p.\,\pageref{classKNetwork_1_1KSocketDevice_a5})}.

Definition at line 65 of file ksocketbase.cpp.

Referenced by set\-Address\-Reuseable(), set\-Blocking(), set\-Broadcast(), and set\-IPv6Only().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!socketOptions@{socketOptions}}
\index{socketOptions@{socketOptions}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KSocket\-Base::socket\-Options () const\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKNetwork_1_1KSocketBase_b1}


Retrieves the socket options that have been set. 

The default implementation just retrieves the mask from an internal variable. Descended classes may choose to override this function to read the values from the operating system.

\begin{Desc}
\item[Returns:]the mask of the options set \end{Desc}


Definition at line 71 of file ksocketbase.cpp.

Referenced by address\-Reuseable(), blocking(), broadcast(), KNetwork::KSocket\-Device::create(), is\-IPv6Only(), KNetwork::KStream\-Socket::KStream\-Socket(), set\-Address\-Reuseable(), set\-Blocking(), set\-Broadcast(), and set\-IPv6Only().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setBlocking@{setBlocking}}
\index{setBlocking@{setBlocking}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::set\-Blocking (bool {\em enable})\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketBase_a2}


Sets this socket's blocking mode. 

In blocking operation, all I/O functions are susceptible to blocking -- i.e., will not return unless the I/O can be satisfied. In non-blocking operation, if the I/O would block, the function will return an error and set the corresponding error code.

The default implementation toggles the Blocking flag with the current socket options and calls {\bf set\-Socket\-Options}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_b0})}.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em enable}]whether to set this socket to blocking mode \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]whether setting this value was successful; it is NOT the final blocking mode. \end{Desc}


Definition at line 76 of file ksocketbase.cpp.

References set\-Socket\-Options(), and socket\-Options().

Referenced by KNetwork::KStream\-Socket::connect(), and KNetwork::KSocks\-Socket\-Device::connect().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!blocking@{blocking}}
\index{blocking@{blocking}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::blocking () const}\label{classKNetwork_1_1KSocketBase_a3}


Retrieves this socket's blocking mode. 

\begin{Desc}
\item[Returns:]true if this socket is/will be operated in blocking mode, false if non-blocking. \end{Desc}


Definition at line 81 of file ksocketbase.cpp.

References socket\-Options().

Referenced by KNetwork::KServer\-Socket::accept(), KNetwork::KServer\-Socket::bind(), KNetwork::KStream\-Socket::connect(), KNetwork::KSocks\-Socket\-Device::connect(), KNetwork::KServer\-Socket::lookup(), KNetwork::KClient\-Socket\-Base::lookup(), and KNetwork::KDatagram\-Socket::receive().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setAddressReuseable@{setAddressReuseable}}
\index{setAddressReuseable@{setAddressReuseable}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::set\-Address\-Reuseable (bool {\em enable})\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketBase_a4}


Sets this socket's address reuseable flag. 

When the address reuseable flag is active, the address used by this socket is left reuseable for other sockets to bind. If the flag is not active, no other sockets may reuse the same address.

The default implementation toggles the Address\-Reuseable flag with the current socket options and calls {\bf set\-Socket\-Options}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_b0})}.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em enable}]whether to set the flag on or off \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if setting this flag was successful \end{Desc}


Definition at line 86 of file ksocketbase.cpp.

References set\-Socket\-Options(), and socket\-Options().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!addressReuseable@{addressReuseable}}
\index{addressReuseable@{addressReuseable}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::address\-Reuseable () const}\label{classKNetwork_1_1KSocketBase_a5}


Retrieves this socket's address reuseability flag. 

\begin{Desc}
\item[Returns:]true if this socket's address can be reused, false if it can't. \end{Desc}


Definition at line 91 of file ksocketbase.cpp.

References socket\-Options().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setIPv6Only@{setIPv6Only}}
\index{setIPv6Only@{setIPv6Only}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::set\-IPv6Only (bool {\em enable})\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketBase_a6}


Sets this socket's IPv6 Only flag. 

When this flag is on, an IPv6 socket will only accept, connect, send to or receive from IPv6 addresses. When it is off, it will also talk to IPv4 addresses through v4-mapped addresses.

This option has no effect on non-IPv6 sockets.

The default implementation toggles the IPv6Only flag with the current socket options and calls {\bf set\-Socket\-Options}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_b0})}.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em enable}]whether to set the flag on or off \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if setting this flag was successful \end{Desc}


Definition at line 96 of file ksocketbase.cpp.

References set\-Socket\-Options(), and socket\-Options().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!isIPv6Only@{isIPv6Only}}
\index{isIPv6Only@{isIPv6Only}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::is\-IPv6Only () const}\label{classKNetwork_1_1KSocketBase_a7}


Retrieves this socket's IPv6 Only flag. 

\begin{Desc}
\item[Returns:]true if this socket will ignore IPv4-compatible and IPv4-mapped addresses, false if it will accept them. \end{Desc}


Definition at line 101 of file ksocketbase.cpp.

References socket\-Options().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setBroadcast@{setBroadcast}}
\index{setBroadcast@{setBroadcast}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::set\-Broadcast (bool {\em enable})\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketBase_a8}


Sets this socket Broadcast flag. 

Datagram-oriented sockets cannot normally send packets to broadcast addresses, nor will they receive packets that were sent to a broadcast address. To do so, you need to enable the Broadcast flag.

This option has no effect on stream-oriented sockets.

\begin{Desc}
\item[Returns:]true if setting this flag was successful. \end{Desc}


Definition at line 106 of file ksocketbase.cpp.

References set\-Socket\-Options(), and socket\-Options().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!broadcast@{broadcast}}
\index{broadcast@{broadcast}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::broadcast () const}\label{classKNetwork_1_1KSocketBase_a9}


Retrieves this socket's Broadcast flag. 

\begin{Desc}
\item[Returns:]true if this socket can send and receive broadcast packets, false if it can't. \end{Desc}


Definition at line 111 of file ksocketbase.cpp.

References socket\-Options().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!socketDevice@{socketDevice}}
\index{socketDevice@{socketDevice}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KSocket\-Device} $\ast$ KSocket\-Base::socket\-Device () const}\label{classKNetwork_1_1KSocketBase_a10}


Retrieves the socket implementation used on this socket. 

This function creates the device if none has been set using the default factory. 

Definition at line 116 of file ksocketbase.cpp.

References mutex(), and set\-Socket\-Device().

Referenced by KNetwork::KServer\-Socket::accept(), KNetwork::KServer\-Socket::bind(), KNetwork::KClient\-Socket\-Base::bind(), KNetwork::KClient\-Socket\-Base::bytes\-Available(), KNetwork::KServer\-Socket::close(), KNetwork::KClient\-Socket\-Base::close(), KNetwork::KBuffered\-Socket::close(), KNetwork::KStream\-Socket::connect(), KNetwork::KClient\-Socket\-Base::connect(), KNetwork::KServer\-Socket::copy\-Error(), KNetwork::KClient\-Socket\-Base::copy\-Error(), KNetwork::KClient\-Socket\-Base::disconnect(), KNetwork::KClient\-Socket\-Base::enable\-Read(), KNetwork::KBuffered\-Socket::enable\-Read(), KNetwork::KClient\-Socket\-Base::enable\-Write(), KNetwork::KBuffered\-Socket::enable\-Write(), KNetwork::KServer\-Socket::external\-Address(), KNetwork::KServer\-Socket::local\-Address(), KNetwork::KClient\-Socket\-Base::local\-Address(), KNetwork::KClient\-Socket\-Base::peek\-Block(), KNetwork::KClient\-Socket\-Base::peer\-Address(), KNetwork::KClient\-Socket\-Base::read\-Block(), KNetwork::KDatagram\-Socket::receive(), KNetwork::KServer\-Socket::set\-Socket\-Options(), KNetwork::KClient\-Socket\-Base::set\-Socket\-Options(), KNetwork::KBuffered\-Socket::slot\-Read\-Activity(), KNetwork::KBuffered\-Socket::slot\-Write\-Activity(), KNetwork::KClient\-Socket\-Base::state\-Changing(), KNetwork::KClient\-Socket\-Base::wait\-For\-More(), KNetwork::KClient\-Socket\-Base::write\-Block(), and KNetwork::KBuffered\-Socket::write\-Block().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setSocketDevice@{setSocketDevice}}
\index{setSocketDevice@{setSocketDevice}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket\-Base::set\-Socket\-Device ({\bf KSocket\-Device} $\ast$ {\em device})\hspace{0.3cm}{\tt  [virtual]}}\label{classKNetwork_1_1KSocketBase_a11}


Sets the socket implementation to be used on this socket. 

Note: it is an error to set this if the socket device has already been set once.

This function is provided virtual so that derived classes can catch the setting of a device and properly set their own states and internal variables. The parent class must be called.

This function is called by {\bf socket\-Device}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a10})} above when the socket is first created. 

Reimplemented in {\bf KNetwork::KBuffered\-Socket} {\rm (p.\,\pageref{classKNetwork_1_1KBufferedSocket_a2})}.

Definition at line 136 of file ksocketbase.cpp.

References mutex().

Referenced by KNetwork::KServer\-Socket::accept(), KNetwork::KSocket\-Device::KSocket\-Device(), and socket\-Device().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setRequestedCapabilities@{setRequestedCapabilities}}
\index{setRequestedCapabilities@{setRequestedCapabilities}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KSocket\-Base::set\-Requested\-Capabilities (int {\em add}, int {\em remove} = {\tt 0})}\label{classKNetwork_1_1KSocketBase_a12}


Sets the internally requested capabilities for a socket device. 

Most socket classes can use any back-end implementation. However, a few may require specific capabilities not provided in the default implementation. By using this function, derived classes can request that a backend with those capabilities be created when necessary.

For the possible flags, see {\bf KSocket\-Device::Capabilities}{\rm (p.\,\pageref{classKNetwork_1_1KSocketDevice_w6})}. However, note that only the Can$\ast$ flags make sense in this context.

\begin{Desc}
\item[Note:]Since socket\-Device must always return a valid backend object, it is is possible that the created device does not conform to all requirements requested. Implementations sensitive to this fact should test the object returned by {\bf socket\-Device}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a10})} (through {\bf KSocket\-Device::capabilities}{\rm (p.\,\pageref{classKNetwork_1_1KSocketDevice_a4})}, for instance) the availability.\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em add}]mask of {\bf KSocket\-Device::Capabilities}{\rm (p.\,\pageref{classKNetwork_1_1KSocketDevice_w6})} to add \item[{\em remove}]mask of bits to remove from the requirements \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]the current mask of requested capabilities \end{Desc}


Definition at line 143 of file ksocketbase.cpp.\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!hasDevice@{hasDevice}}
\index{hasDevice@{hasDevice}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::has\-Device () const\hspace{0.3cm}{\tt  [protected]}}\label{classKNetwork_1_1KSocketBase_b2}


Returns true if the socket device has been initialised in this object, either by calling {\bf socket\-Device()}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a10})} or {\bf set\-Socket\-Device}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a11})}. 



Definition at line 150 of file ksocketbase.cpp.

Referenced by KNetwork::KClient\-Socket\-Base::set\-Socket\-Options().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!setError@{setError}}
\index{setError@{setError}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket\-Base::set\-Error ({\bf Socket\-Error} {\em error})\hspace{0.3cm}{\tt  [protected]}}\label{classKNetwork_1_1KSocketBase_b3}


Sets the socket's error code. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em error}]the error code \end{description}
\end{Desc}


Definition at line 155 of file ksocketbase.cpp.

Referenced by KNetwork::KServer\-Socket::accept(), KNetwork::KServer\-Socket::bind(), KNetwork::KServer\-Socket::copy\-Error(), and KNetwork::KServer\-Socket::lookup().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!error@{error}}
\index{error@{error}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KSocket\-Base::Socket\-Error} KSocket\-Base::error () const}\label{classKNetwork_1_1KSocketBase_a13}


Retrieves the socket error code. 

\begin{Desc}
\item[See also:]{\bf error\-String}{\rm (p.\,\pageref{classKNetwork_1_1KSocketBase_a14})} \end{Desc}


Definition at line 160 of file ksocketbase.cpp.

Referenced by KNetwork::KStream\-Socket::connect(), KNetwork::KClient\-Socket\-Base::connect(), KNetwork::KServer\-Socket::copy\-Error(), KNetwork::KClient\-Socket\-Base::copy\-Error(), KNetwork::KClient\-Socket\-Base::peek\-Block(), KNetwork::KClient\-Socket\-Base::read\-Block(), KNetwork::KBuffered\-Socket::slot\-Read\-Activity(), KNetwork::KBuffered\-Socket::slot\-Write\-Activity(), KNetwork::KClient\-Socket\-Base::wait\-For\-More(), and KNetwork::KClient\-Socket\-Base::write\-Block().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!errorString@{errorString}}
\index{errorString@{errorString}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KNetwork::KSocket\-Base::error\-String () const\hspace{0.3cm}{\tt  [inline]}}\label{classKNetwork_1_1KSocketBase_a14}


Returns the error string corresponding to this error condition. 



Definition at line 383 of file ksocketbase.h.\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!mutex@{mutex}}
\index{mutex@{mutex}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QMutex} $\ast$ KSocket\-Base::mutex () const}\label{classKNetwork_1_1KSocketBase_a15}


Returns the internal mutex for this class. 

Note on multithreaded use of sockets: the socket classes are thread-safe by design, but you should be aware of problems regarding socket creation, connection and destruction in multi-threaded programs. The classes are guaranteed to work while the socket exists, but it's not wise to call connect in multiple threads.

Also, this mutex must be unlocked before the object is destroyed, which means you cannot use it to guard against other threads accessing the object while destroying it. You must ensure there are no further references to this object when deleting it. 

Definition at line 278 of file ksocketbase.cpp.

Referenced by KNetwork::KClient\-Socket\-Base::enable\-Read(), KNetwork::KClient\-Socket\-Base::enable\-Write(), KNetwork::KSocket\-Device::exception\-Notifier(), KNetwork::KSocket\-Device::read\-Notifier(), KNetwork::KBuffered\-Socket::set\-Input\-Buffering(), KNetwork::KBuffered\-Socket::set\-Output\-Buffering(), set\-Socket\-Device(), KNetwork::KSocket\-Device::set\-Socket\-Options(), KNetwork::KServer\-Socket::set\-Socket\-Options(), KNetwork::KClient\-Socket\-Base::set\-Socket\-Options(), KNetwork::KBuffered\-Socket::slot\-Read\-Activity(), KNetwork::KBuffered\-Socket::slot\-Write\-Activity(), socket\-Device(), and KNetwork::KSocket\-Device::write\-Notifier().\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!errorString@{errorString}}
\index{errorString@{errorString}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KSocket\-Base::error\-String ({\bf Socket\-Error} {\em code})\hspace{0.3cm}{\tt  [static]}}\label{classKNetwork_1_1KSocketBase_e0}


Returns the string describing the given error code, i18n'ed. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em code}]the error code \end{description}
\end{Desc}


Definition at line 166 of file ksocketbase.cpp.\index{KNetwork::KSocketBase@{KNetwork::KSocket\-Base}!isFatalError@{isFatalError}}
\index{isFatalError@{isFatalError}!KNetwork::KSocketBase@{KNetwork::KSocket\-Base}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KSocket\-Base::is\-Fatal\-Error (int {\em code})\hspace{0.3cm}{\tt  [static]}}\label{classKNetwork_1_1KSocketBase_e1}


Returns true if the given error code is a fatal one, false otherwise. 

The parameter here is of type int so that casting isn't necessary when using the parameter to signal QClient\-Socket\-Base::got\-Error.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em code}]the code to test \end{description}
\end{Desc}


Definition at line 259 of file ksocketbase.cpp.

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