举个例子(etc.)TEMP_FAILURE_RETRY(::accept(sock, (struct sockaddr*)addr, &len));
它的功能: 不断地从套接口中接收客户端的地址知道成功为止返回客户端的可用套接口.
顺便写一个利用epoll技术来接收数据的routine
int accept(struct sockaddr_in *addr)
{
socklen_t len = sizeof(struct sockaddr_in);
bzero(addr, sizeof(struct sockaddr_in));
struct epoll_event ev;
int rc = epoll_wait(kdpfd, &ev, 1, 2000);//这里kdpfd is the library function epoll_create(
int size)的reture value.Here is called by epoll_create(1).You can man it.
if(1 == rc && (ev.events & EPOLLIN))
return TEMP_FAILURE_RETRY(::accept(sock, (struct sockaddr*)addr, &len));
return -1;
}