全部博文(168)
分类: LINUX
2009-10-01 00:31:56
1、client端进程挂掉后, server端poll收到的POLLIN不是HUP,ERR
2、当poll监视的fd被关闭时, poll并不能及时发现,通常有很大的延迟.不可用来做实时处理.code snatch
fdarray[0].fd = sock;
fdarray[0].events = POLLIN;
fdarray[0].revents = 0;
fdarray[1].fd = udpsock;
fdarray[1].events = POLLIN;
fdarray[1].revents = 0;
printf("poll ... ...\n");
ret = poll(fdarray, 2, -1);
printf("poll ret == %d\n", ret);
if (ret < 0) {
perror("poll err");
}
if (ret > 0) {
if (fdarray[0].revents&(POLLNVAL|POLLIN)) {
if (fdarray[0].revents&POLLNVAL)
printf("sock have except ,,\n");
else if (fdarray[0].revents&POLLIN)
printf("sock have pollin ,,\n");
/* release some resource */
pthread_exit(NULL);
}
if (fdarray[1].revents&POLLIN) {
printf("udpsock have pollin\n");
/* read pkt and reply */
}
}