1 int main(int argc, char *argv[])
8 /* Main code begin here */
9 if (compat) { /* install signal handler */
10 Signal(SIGCHLD, HandSigCHLD); /* non restarting handler */
12 SignalRestart(SIGCHLD, HandSigCHLD); /* restarting handler */
17 if (listen(list_fd, BACKLOG) < 0 ) {
18 PrintErr("listen error");
21 if (waiting) sleep(waiting);
22 /* handle echo to client */
24 /* accept connection */
25 len = sizeof(cli_add);
26 while (((conn_fd = accept(list_fd, (struct sockaddr *)&cli_add, &len))
27 < 0) && (errno == EINTR));
29 PrintErr("accept error");
33 inet_ntop(AF_INET, &cli_add.sin_addr, ipaddr, sizeof(ipaddr));
34 snprintf(debug, MAXLINE, "Accepted connection form %s\n", ipaddr);
36 syslog(LOG_DEBUG, debug);
41 /* fork to handle connection */