Вопрос

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