listen_8c.tex 2.03 KB
\hypertarget{listen_8c}{
\section{src/socket/listen.c File Reference}
\label{listen_8c}\index{src/socket/listen.c@{src/socket/listen.c}}
}
{\ttfamily \#include $<$stdlib.h$>$}\par
{\ttfamily \#include $<$errno.h$>$}\par
{\ttfamily \#include \char`\"{}socket.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}interface/class.h\char`\"{}}\par
{\ttfamily \#include \char`\"{}interface/logger.h\char`\"{}}\par
Include dependency graph for listen.c:
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{listen_8c_a757c220e9371523ef55b1137a1efed57}{socketListen} (\hyperlink{structSock}{Sock} this, int backlog)
\end{DoxyCompactItemize}


\subsection{Function Documentation}
\hypertarget{listen_8c_a757c220e9371523ef55b1137a1efed57}{
\index{listen.c@{listen.c}!socketListen@{socketListen}}
\index{socketListen@{socketListen}!listen.c@{listen.c}}
\subsubsection[{socketListen}]{\setlength{\rightskip}{0pt plus 5cm}void socketListen (
\begin{DoxyParamCaption}
\item[{{\bf Sock}}]{this, }
\item[{int}]{backlog}
\end{DoxyParamCaption}
)}}
\label{listen_8c_a757c220e9371523ef55b1137a1efed57}


Definition at line 10 of file listen.c.


\begin{DoxyCode}
{
    (this->addr).sin_family      = AF_INET;           /* Internet address family 
      */
    (this->addr).sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface *
      /
    (this->addr).sin_port        = htons(this->port); /* Local port */

    /* Bind to the local address */
    if (-1 == bind(this->handle, (struct sockaddr *) &(this->addr), sizeof(this->
      addr))) {
        loggerLog(this->log, LOGGER_CRIT,
                "error binding socket: %s - service terminated",
                strerror(errno));
        exit(EXIT_FAILURE);
    }

    /* Mark the socket so it will listen for incoming connections */
    if (-1 == listen(this->handle, backlog)) {
        loggerLog(this->log, LOGGER_CRIT,
                "error binding socket: %s - service terminated",
                strerror(errno));
        exit(EXIT_FAILURE);
    }
}
\end{DoxyCode}


Here is the call graph for this function: