|
谢谢楼上的。
我设置成非阻塞后。 FD_ISSET()总是返回非0
/*create socket*/
UDPCreate_Recv();
ioctl(sock_udp_recv, FIONBIO, &ul)
bind(sock_udp_recv, (struct sockaddr_in*)&addr_udp_recv, sizeof(addr_udp_recv));
while(1)
{
FD_ZERO(&fd_read);
FD_SET(sock_udp_recv, &fd_read);
timeout_recv.tv_sec = 1;
timeout_recv.tv_usec = 1;
nret = select(0, &fd_read, 0, 0, &timeout_recv);
/*问下,这里总是返回为非0*/
nret = FD_ISSET(sock_udp_recv, &fd_read); if(!nret)
{
continue;
}
recvfrom(...)
} |
|