문제

I am trying to read data from a file using NIO. The thing is that the file is not just any file, but a file emulating a network device, i.e the tun0. Various reasons mention the fact that the Selector cannot be used since the file is always present, but in this case its data is constantly changing and I need to receive that event immediately without having to poll.

So is there some way in which I can use the Selector, and if not, what are, if any, the similar high performance options?

Thank you.

도움이 되었습니까?

해결책

A FileChannel is not a SelectableChannel and therefore cannot be used with a Selector.

The 'various reasons' you quote aren't correct. You can use a file FD with select() in Unix.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top