\section{KServer\-Socket Class Reference}
\label{classKServerSocket}\index{KServerSocket@{KServerSocket}}
{\bf This class or method is obsolete, it is provided for compatibility only.} Please use the more powerful {\bf KExtended\-Socket}{\rm (p.\,\pageref{classKExtendedSocket})} class. Monitors a port for incoming TCP/IP connections.  


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

Inheritance diagram for KServer\-Socket:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=59pt]{classKServerSocket__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KServer\-Socket:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=59pt]{classKServerSocket__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
virtual void {\bf slot\-Accept} (int)
\begin{CompactList}\small\item\em Called when someone connected to our port. \item\end{CompactList}\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf accepted} ({\bf KSocket} $\ast$s)
\begin{CompactList}\small\item\em A connection has been accepted. \item\end{CompactList}\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KServer\-Socket} (unsigned short int \_\-port, bool \_\-bind=true)
\begin{CompactList}\small\item\em Constructor. \item\end{CompactList}\item 
{\bf KServer\-Socket} (const  char $\ast$\_\-path, bool \_\-bind=true)
\begin{CompactList}\small\item\em Creates a UNIX domain server socket. \item\end{CompactList}\item 
virtual {\bf $\sim$KServer\-Socket} ()
\begin{CompactList}\small\item\em Destructor. \item\end{CompactList}\item 
bool {\bf bind\-And\-Listen} ()
\begin{CompactList}\small\item\em Binds the socket and start listening. \item\end{CompactList}\item 
int {\bf socket} () const 
\begin{CompactList}\small\item\em Returns the file descriptor associated with the socket. \item\end{CompactList}\item 
unsigned short int {\bf port} ()
\begin{CompactList}\small\item\em Returns the port number which is being monitored. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
bool {\bf init} (unsigned short int)\label{classKServerSocket_b0}

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

\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
int {\bf sock}
\begin{CompactList}\small\item\em The file descriptor for this socket. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
{\bf This class or method is obsolete, it is provided for compatibility only.} Please use the more powerful {\bf KExtended\-Socket}{\rm (p.\,\pageref{classKExtendedSocket})} class. Monitors a port for incoming TCP/IP connections. 

You can use a KServer\-Socket to listen on a port for incoming connections. When a connection arrived in the port, a {\bf KSocket}{\rm (p.\,\pageref{classKSocket})} is created and the signal accepted is raised. Make sure you always connect to this signal. If you don't the Server\-Socket will create new KSocket's and no one will delete them!

If {\bf socket()}{\rm (p.\,\pageref{classKServerSocket_a4})} is -1 or less the socket was not created properly.

\begin{Desc}
\item[Author:]Torben Weis $<${\tt weis@stud.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 241 of file ksock.h.

\subsection{Constructor \& Destructor Documentation}
\index{KServerSocket@{KServer\-Socket}!KServerSocket@{KServerSocket}}
\index{KServerSocket@{KServerSocket}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KServer\-Socket::KServer\-Socket (unsigned short int {\em \_\-port}, bool {\em \_\-bind} = true)}\label{classKServerSocket_a0}


Constructor. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-port}]the port number to monitor for incoming connections. \item[{\em \_\-bind}]if false you need to call {\bf bind\-And\-Listen}{\rm (p.\,\pageref{classKServerSocket_a3})} yourself. This gives you the opportunity to set options on the socket. \end{description}
\end{Desc}


Definition at line 292 of file ksock.cpp.\index{KServerSocket@{KServer\-Socket}!KServerSocket@{KServerSocket}}
\index{KServerSocket@{KServerSocket}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KServer\-Socket::KServer\-Socket (const char $\ast$ {\em \_\-path}, bool {\em \_\-bind} = true)}\label{classKServerSocket_a1}


Creates a UNIX domain server socket. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em \_\-path}]path used for the socket. \item[{\em \_\-bind}]if false you need to call {\bf bind\-And\-Listen}{\rm (p.\,\pageref{classKServerSocket_a3})} yourself. This gives you the opportunity to set options on the socket. \end{description}
\end{Desc}


Definition at line 283 of file ksock.cpp.\index{KServerSocket@{KServer\-Socket}!~KServerSocket@{$\sim$KServerSocket}}
\index{~KServerSocket@{$\sim$KServerSocket}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KServer\-Socket::$\sim${\bf KServer\-Socket} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKServerSocket_a2}


Destructor. 

Closes the socket if it was not already closed. 

Definition at line 419 of file ksock.cpp.

\subsection{Member Function Documentation}
\index{KServerSocket@{KServer\-Socket}!bindAndListen@{bindAndListen}}
\index{bindAndListen@{bindAndListen}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KServer\-Socket::bind\-And\-Listen ()}\label{classKServerSocket_a3}


Binds the socket and start listening. 

This should only be called once when the constructor was called with \_\-bind false. On error the socket will be closed. \begin{Desc}
\item[Returns:]true on success. false on error. \end{Desc}


Definition at line 329 of file ksock.cpp.

References QObject::connect(), slot\-Accept(), and sock.\index{KServerSocket@{KServer\-Socket}!socket@{socket}}
\index{socket@{socket}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KServer\-Socket::socket () const\hspace{0.3cm}{\tt  [inline]}}\label{classKServerSocket_a4}


Returns the file descriptor associated with the socket. 

\begin{Desc}
\item[Returns:]the file descriptor, -1 when an error occured during construction or {\bf bind\-And\-Listen}{\rm (p.\,\pageref{classKServerSocket_a3})} \end{Desc}


Definition at line 281 of file ksock.h.

References sock.\index{KServerSocket@{KServer\-Socket}!port@{port}}
\index{port@{port}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned short int KServer\-Socket::port ()}\label{classKServerSocket_a5}


Returns the port number which is being monitored. 

\begin{Desc}
\item[Returns:]the port number \end{Desc}


Definition at line 353 of file ksock.cpp.

References KSocket\-Address::address(), kde\_\-sockaddr\_\-in6::sin6\_\-port, and sock.\index{KServerSocket@{KServer\-Socket}!slotAccept@{slotAccept}}
\index{slotAccept@{slotAccept}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KServer\-Socket::slot\-Accept (int)\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKServerSocket_i0}


Called when someone connected to our port. 



Definition at line 400 of file ksock.cpp.

References accepted(), KExtended\-Socket::fd(), KExtended\-Socket::release(), and sock.

Referenced by bind\-And\-Listen().\index{KServerSocket@{KServer\-Socket}!accepted@{accepted}}
\index{accepted@{accepted}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KServer\-Socket::accepted ({\bf KSocket} $\ast$ {\em s})\hspace{0.3cm}{\tt  [signal]}}\label{classKServerSocket_l0}


A connection has been accepted. 

It is your task to delete the {\bf KSocket}{\rm (p.\,\pageref{classKSocket})} if it is no longer needed.

WARNING: this signal is always emitted, even if you don't connect anything to it. That would mean memory loss, because the KSockets created go to oblivion. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em s}]the socket that accepted \end{description}
\end{Desc}


Referenced by slot\-Accept().

\subsection{Member Data Documentation}
\index{KServerSocket@{KServer\-Socket}!sock@{sock}}
\index{sock@{sock}!KServerSocket@{KServer\-Socket}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int {\bf KServer\-Socket::sock}\hspace{0.3cm}{\tt  [protected]}}\label{classKServerSocket_p0}


The file descriptor for this socket. 

sock may be -1. This indicates that it is not connected. 

Definition at line 326 of file ksock.h.

Referenced by bind\-And\-Listen(), port(), slot\-Accept(), and socket().

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