\section{KSocket Class Reference}
\label{classKSocket}\index{KSocket@{KSocket}}
You can connect this socket to any Internet address. A TCP/IP client socket.  


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

Inheritance diagram for KSocket:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=43pt]{classKSocket__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KSocket:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=43pt]{classKSocket__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
void {\bf slot\-Write} (int x)
\begin{CompactList}\small\item\em Connected to the write\-Notifier. \item\end{CompactList}\item 
void {\bf slot\-Read} (int x)
\begin{CompactList}\small\item\em Connected to the read\-Notifier. \item\end{CompactList}\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf read\-Event} ({\bf KSocket} $\ast$s)
\begin{CompactList}\small\item\em Data has arrived for reading. \item\end{CompactList}\item 
void {\bf write\-Event} ({\bf KSocket} $\ast$s)
\begin{CompactList}\small\item\em Socket is ready for writing. \item\end{CompactList}\item 
void {\bf close\-Event} ({\bf KSocket} $\ast$s)
\begin{CompactList}\small\item\em Raised when the connection is broken. \item\end{CompactList}\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KSocket} (int \_\-sock)
\begin{CompactList}\small\item\em Constructs a KSocket with the provided file descriptor. \item\end{CompactList}\item 
{\bf KSocket} (const  char $\ast$\_\-host, unsigned short int \_\-port, int time\-Out=30)
\begin{CompactList}\small\item\em Creates a socket and connects to a host. \item\end{CompactList}\item 
{\bf KSocket} (const  char $\ast$\_\-path)
\begin{CompactList}\small\item\em Connects to a UNIX domain socket. \item\end{CompactList}\item 
virtual {\bf $\sim$KSocket} ()
\begin{CompactList}\small\item\em Destructor. \item\end{CompactList}\item 
int {\bf socket} () const 
\begin{CompactList}\small\item\em Returns a file descriptor for this socket. \item\end{CompactList}\item 
void {\bf enable\-Read} (bool enable)
\begin{CompactList}\small\item\em Enables the socket for reading. \item\end{CompactList}\item 
void {\bf enable\-Write} (bool enable)
\begin{CompactList}\small\item\em Enables the socket for writing. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
bool {\bf connect} (const  {\bf QString} \&\_\-host, unsigned short int \_\-port, int timeout=0)\label{classKSocket_b0}

\item 
bool {\bf connect} (const  char $\ast$\_\-path)\label{classKSocket_b1}

\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
int {\bf sock}\label{classKSocket_p0}

\end{CompactItemize}


\subsection{Detailed Description}
You can connect this socket to any Internet address. A TCP/IP client socket. 

The socket gives you three signals: When ready for reading, ready for writing or if the connection is broken. Using {\bf socket}{\rm (p.\,\pageref{classKSocket_a4})}() you get a file descriptor which you can use with the usual UNIX function like write() or read(). If you have already such a socket identifier you can construct a KSocket on this identifier.

If {\bf socket}{\rm (p.\,\pageref{classKSocket_a4})}() delivers a value of -1 or less, the connection was not successful.

\begin{Desc}
\item[Author:]Torben Weis $<${\tt weis@uni-frankfurt.de}$>$ \end{Desc}
\begin{Desc}
\item[Version:]\begin{Desc}
\item[Id]{\bf ksock.h}{\rm (p.\,\pageref{ksock_8h})},v 1.53 2002/09/09 21:24:53 tjansen Exp \end{Desc}
\end{Desc}




Definition at line 81 of file ksock.h.

\subsection{Constructor \& Destructor Documentation}
\index{KSocket@{KSocket}!KSocket@{KSocket}}
\index{KSocket@{KSocket}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket::KSocket (int {\em \_\-sock})}\label{classKSocket_a0}


Constructs a KSocket with the provided file descriptor. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-sock}]The file descriptor to use. \end{description}
\end{Desc}


Definition at line 101 of file ksock.cpp.

References KSocks::getsockname(), and KSocks::self().\index{KSocket@{KSocket}!KSocket@{KSocket}}
\index{KSocket@{KSocket}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket::KSocket (const char $\ast$ {\em \_\-host}, unsigned short int {\em \_\-port}, int {\em time\-Out} = 30)}\label{classKSocket_a1}


Creates a socket and connects to a host. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-host}]The remote host to which to connect. \item[{\em \_\-port}]The port on the remote host. \item[{\em time\-Out}]The number of seconds waiting for connect (default 30). \end{description}
\end{Desc}


Definition at line 115 of file ksock.cpp.

References QObject::connect().\index{KSocket@{KSocket}!KSocket@{KSocket}}
\index{KSocket@{KSocket}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket::KSocket (const char $\ast$ {\em \_\-path})}\label{classKSocket_a2}


Connects to a UNIX domain socket. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-path}]The filename of the socket. \end{description}
\end{Desc}


Definition at line 121 of file ksock.cpp.

References QObject::connect().\index{KSocket@{KSocket}!~KSocket@{$\sim$KSocket}}
\index{~KSocket@{$\sim$KSocket}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KSocket::$\sim${\bf KSocket} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKSocket_a3}


Destructor. 

Closes the socket if it is still open. 

Definition at line 260 of file ksock.cpp.

\subsection{Member Function Documentation}
\index{KSocket@{KSocket}!socket@{socket}}
\index{socket@{socket}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KSocket::socket () const\hspace{0.3cm}{\tt  [inline]}}\label{classKSocket_a4}


Returns a file descriptor for this socket. 

\begin{Desc}
\item[Returns:]the file descriptor, or -1 when an error occured. \end{Desc}


Definition at line 113 of file ksock.h.\index{KSocket@{KSocket}!enableRead@{enableRead}}
\index{enableRead@{enableRead}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket::enable\-Read (bool {\em enable})}\label{classKSocket_a5}


Enables the socket for reading. 

If you enable read mode, the socket will emit the signal {\bf read\-Event}{\rm (p.\,\pageref{classKSocket_l0})}() whenever there is something to read out of this socket. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em enable}]true to enable reading signals \end{description}
\end{Desc}


Definition at line 127 of file ksock.cpp.

References QObject::connect(), and slot\-Read().\index{KSocket@{KSocket}!enableWrite@{enableWrite}}
\index{enableWrite@{enableWrite}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket::enable\-Write (bool {\em enable})}\label{classKSocket_a6}


Enables the socket for writing. 

If you enable write mode, the socket will emit the signal {\bf write\-Event}{\rm (p.\,\pageref{classKSocket_l1})}() whenever the socket is ready for writing.

Warning: If you forget to call enable\-Write(false) when you are not ready to send data, you will get lots of {\bf write\-Event()}{\rm (p.\,\pageref{classKSocket_l1})} signals, in the order of thousands a second ! \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em enable}]true to enable writing signals \end{description}
\end{Desc}


Definition at line 143 of file ksock.cpp.

References QObject::connect(), and slot\-Write().\index{KSocket@{KSocket}!readEvent@{readEvent}}
\index{readEvent@{readEvent}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket::read\-Event ({\bf KSocket} $\ast$ {\em s})\hspace{0.3cm}{\tt  [signal]}}\label{classKSocket_l0}


Data has arrived for reading. 

This signal will only be raised if {\bf enable\-Read}{\rm (p.\,\pageref{classKSocket_a5})}( {\tt true} ) was called first. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em s}]the KSocket that triggered the event \end{description}
\end{Desc}


Referenced by slot\-Read().\index{KSocket@{KSocket}!writeEvent@{writeEvent}}
\index{writeEvent@{writeEvent}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket::write\-Event ({\bf KSocket} $\ast$ {\em s})\hspace{0.3cm}{\tt  [signal]}}\label{classKSocket_l1}


Socket is ready for writing. 

This signal will only be raised if {\bf enable\-Write}{\rm (p.\,\pageref{classKSocket_a6})}( {\tt true} ) was called first.

Warning: If you forget to call enable\-Write(false) when you are not ready to send data, you will get lots of {\bf write\-Event()}{\rm (p.\,\pageref{classKSocket_l1})} signals, in the order of thousands a second ! \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em s}]the KSocket that triggered the event \end{description}
\end{Desc}


Referenced by slot\-Write().\index{KSocket@{KSocket}!closeEvent@{closeEvent}}
\index{closeEvent@{closeEvent}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket::close\-Event ({\bf KSocket} $\ast$ {\em s})\hspace{0.3cm}{\tt  [signal]}}\label{classKSocket_l2}


Raised when the connection is broken. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em s}]the KSocket that triggered the event \end{description}
\end{Desc}


Referenced by slot\-Read().\index{KSocket@{KSocket}!slotWrite@{slotWrite}}
\index{slotWrite@{slotWrite}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket::slot\-Write (int {\em x})\hspace{0.3cm}{\tt  [slot]}}\label{classKSocket_i0}


Connected to the write\-Notifier. 

Called when the socket is ready for writing. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em x}]ignored \end{description}
\end{Desc}


Definition at line 171 of file ksock.cpp.

References write\-Event().

Referenced by enable\-Write().\index{KSocket@{KSocket}!slotRead@{slotRead}}
\index{slotRead@{slotRead}!KSocket@{KSocket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KSocket::slot\-Read (int {\em x})\hspace{0.3cm}{\tt  [slot]}}\label{classKSocket_i1}


Connected to the read\-Notifier. 

Called when the socket is ready for reading. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em x}]ignored \end{description}
\end{Desc}


Definition at line 160 of file ksock.cpp.

References close\-Event(), and read\-Event().

Referenced by enable\-Read().

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