23,118
社区成员
发帖
与我相关
我的任务
分享
int select_ret;
struct timeval timeout = {3,0};
int maxfd = remote_sock_fd + 1;
fd_set sel_fds;
while(!process_exit){
//asynchronous
FD_ZERO(&sel_fds);
FD_SET(remote_sock_fd,&sel_fds);
printf("Starting select() \n"); // 打印select之前的断点
select_ret = select(maxfd,&sel_fds,NULL,NULL,&timeout);
switch(select_ret){
case 0:
printf("select() timeout \n");
break;
case -1:
printf("Error occurs when select() \n");
break;
default:
if(FD_ISSET(remote_sock_fd,&sel_fds)){
recv_from_remote();
}
}