23,131
社区成员
发帖
与我相关
我的任务
分享
pid_t pid;
int listenfd , connfd;
listenfd = socket(....);
bind(listenfd,....);
listen(listenfd,0);
for(; ; ) {
connfd = accept(listenfd, .....);
## if(( pid = fork()) == 0) {
.....
close(listenfd);
......// do something
close(connfd);
exit(0);
}
close(connfd);
}