\section{socket\_\-accept.c File Reference}
\label{socket__accept_8c}\index{socket_accept.c@{socket\_\-accept.c}}
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include \char`\"{}libcomm.h\char`\"{}}\par
{\tt \#include $<$pthread.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf thread2} (struct {\bf LIBCOMMPTHREADP} $\ast$libcommpthreadp)
\begin{CompactList}\small\item\em This is a part of {\bf socket\_\-accept}() {\rm (p.\,\pageref{libcomm_8h_a11})} and must not called from the user.\item\end{CompactList}\item 
int {\bf socket\_\-accept} (int sockport, int id, void($\ast$socket\_\-accept\_\-do)(int fd, int id, char $\ast$pip, struct sockaddr\_\-in their\_\-addr))
\begin{CompactList}\small\item\em Start a new thread, wait for connections and start socket\_\-accept\_\-do() when someone connects.\item\end{CompactList}\end{CompactItemize}


\subsection{Function Documentation}
\index{socket_accept.c@{socket\_\-accept.c}!socket_accept@{socket\_\-accept}}
\index{socket_accept@{socket\_\-accept}!socket_accept.c@{socket\_\-accept.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int socket\_\-accept (int {\em sockport}, int {\em id}, void($\ast$ {\em socket\_\-accept\_\-do})(int fd, int id, char $\ast$pip, struct sockaddr\_\-in their\_\-addr))}\label{socket__accept_8c_a1}


Start a new thread, wait for connections and start socket\_\-accept\_\-do() when someone connects.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
sockport}](int) descriptor of a tcp socket/port from {\bf socket\_\-bind}() {\rm (p.\,\pageref{libcomm_8h_a20})}\item[{\em 
id}](int) arbitrary id of background process / thread. (May be it is a good idea to use the portnumber.)\item[{\em 
aocket\_\-accept\_\-do}](int fd, int id, char $\ast$pip, struct sockaddr\_\-in their\_\-addr) (function) this function is called if somebody connects. fd is the descriptor of the new socket to the connected tcp-tream. id is the same as in {\bf socket\_\-accept}() {\rm (p.\,\pageref{libcomm_8h_a11})}. pip contains the ip-address of the connected client. The structure their\_\-addr contails all known information about the connected client.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
If all right zero otherwise non zero. \end{Desc}
\index{socket_accept.c@{socket\_\-accept.c}!thread2@{thread2}}
\index{thread2@{thread2}!socket_accept.c@{socket\_\-accept.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void thread2 (struct {\bf LIBCOMMPTHREADP} $\ast$ {\em libcommpthreadp})}\label{socket__accept_8c_a0}


This is a part of {\bf socket\_\-accept}() {\rm (p.\,\pageref{libcomm_8h_a11})} and must not called from the user.

This function is the thread which is started from {\bf socket\_\-accept}() {\rm (p.\,\pageref{libcomm_8h_a11})} and runs in background. 