\hypertarget{accept_8c}{ \section{src/socket/accept.c File Reference} \label{accept_8c}\index{src/socket/accept.c@{src/socket/accept.c}} } {\ttfamily \#include $<$errno.h$>$}\par {\ttfamily \#include $<$unistd.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 accept.c: \subsection*{Functions} \begin{DoxyCompactItemize} \item \hyperlink{structSock}{Sock} \hyperlink{accept_8c_a46aa6b495ccf752e844f93bf46c9edd6}{socketAccept} (\hyperlink{structSock}{Sock} this, char remoteAddr\mbox{[}16\mbox{]}) \end{DoxyCompactItemize} \subsection{Function Documentation} \hypertarget{accept_8c_a46aa6b495ccf752e844f93bf46c9edd6}{ \index{accept.c@{accept.c}!socketAccept@{socketAccept}} \index{socketAccept@{socketAccept}!accept.c@{accept.c}} \subsubsection[{socketAccept}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Sock} socketAccept ( \begin{DoxyParamCaption} \item[{{\bf Sock}}]{this, } \item[{char}]{remoteAddr\mbox{[}16\mbox{]}} \end{DoxyParamCaption} )}} \label{accept_8c_a46aa6b495ccf752e844f93bf46c9edd6} : Uhh, this is bad. we open a new socket additionally to the one we get from the accept call. i have to change the socket constructor to be able to create the data structure without creation of a socket at all. For now i simply close the socket here.... :D : change port to remote port on success Definition at line 9 of file accept.c. \begin{DoxyCode} { Sock sock; /* Socket for client */ unsigned int len; /* Length of client address data structure */ /* Set the size of the in-out parameter */ len = sizeof(this->addr); sock = new(Sock, this->log, this->port); close(sock->handle); /* Wait for a client to connect */ sock->handle = accept(this->handle, (struct sockaddr *) &(sock->addr), &len); if (-1 == sock->handle) { loggerLog(this->log, LOGGER_WARNING, "error accepting connection: %s", strerror(errno)); } else { loggerLog(this->log, LOGGER_INFO, "handling client %s\n", inet_ntoa((sock->addr).si n_addr)); } return sock; } \end{DoxyCode} Here is the call graph for this function: