- 论坛徽章:
- 0
|
原帖由 czshjh 于 2006-6-20 17:02 发表
仔细看一下你的程序,你的程序中,无论何种情况,都不会走到close( new_fd)和close( listenfd)的
这是server.c
while(1)
{
int new_fd;
if(-1 == ( new_fd = accept( listenfd, ( struct sockaddr *)&client, &sin_size)))
{
printf(" accept() error.\n");
exit(1);
}
memset(hello ,0,sizeof(hello));
// 阻塞读
if(read(new_fd,hello,1024*5)<0){
printf(" read error.\n");
close(new_fd);
continue;
}
printf("len=%d,Recv=%s\n",strlen(hello),hello);
/* 关闭 */
close(new_fd); *************************这能走到 了呀*****
}
上面的
close(new_fd); 可以走到
也就是每个连接都 close(new_fd);了 |
|