Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

Commit 0f528f0

Browse files
committed
To select passive file descriptor
1 parent 2e7f6ba commit 0f528f0

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

func.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
void func(int newsockfd)
3+
{
4+
int maxfd;
5+
int nready;
6+
fd_set fds;
7+
8+
maxfd = newsockfd + 1;
9+
FD_ZERO(&fds);
10+
FD_SET(newsockfd,&fds);
11+
12+
13+
while(1)
14+
{
15+
nready = select(maxfd,&fds,(fd_set *)0,(fd_set *)0,(struct timeval *)0);
16+
if(nready < 1)
17+
continue;
18+
if(FD_ISSET(newsockfd,&fds))
19+
break;
20+
}
21+
22+
}

0 commit comments

Comments
 (0)