- 论坛徽章:
- 0
|
帮忙看一下为什么用select不阻塞?
代码的实现为:
fd_set rset,allset;
listenfd = ServLisen(tcp_port); //见上
//SetLinger(listenfd,lin);
maxfd=listenfd;
FD_ZERO(&allset);
FD_SET(listenfd,&allset);
for (;
{
rset = allset;
isread = select(maxfd+1, &rset , NULL, NULL, NULL);
if (FD_ISSET(listenfd,&rset ))//&allset
{
if ((connfd=accept(listenfd,(struct sockadd *)&clienaddr,&clilen))<0)
{
if ((errno==EINTR)||(errno==EWOULDBLOCK)||(errno==ECONNABORTED))
{
//close(connfd);
printf("==== wrong in the accept with interapt from client ====\n" ;
continue;
}
else
{
printf("accept error\n" ;
close(connfd);
}
}
}
}
大概是这样。 |
|