3 if (listen(list_fd, BACKLOG) < 0 ) { /* listen on socket */
4 PrintErr("listen error");
7 while (1) { /* handle echo to client */
9 if ( (conn_fd = accept(list_fd, NULL, NULL)) < 0) {
10 PrintErr("accept error");
13 if ( (pid = fork()) < 0 ) { /* fork to handle connection */
14 PrintErr("fork error");
17 if (pid == 0) { /* child */
18 close(list_fd); /* close listening socket */
19 ServEcho(conn_fd); /* handle echo */
22 close(conn_fd); /* close connected socket */
25 exit(0); /* normal exit, never reached */