main() { USER *userTable; initUserTable(userTable); ..... while(1) { clilen=sizeof(addrcli); connfd=accept(listenfd,(struct sockaddr *)&addrcli,&clilen); if( (childpid=fork()) > 0 ) { close(connfd); continue; } else if (childpid==0) { doit(userTable,connfd,&addrcli); close(connfd); } } } int doit(USER *userTable,int connfd,struct sockaddr_in *addr) { USER *user; if (!(user=(USER *)malloc(sizeof(USER)))); { test("malloc bad\n");//打印信息 return -1; } .... } |
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |