Java equivalent of C's poll()?
Asked Answered
D

1

12

As the title suggests, I'd like to know what is Java's equivalent (or most similar) function to C's poll() function for polling a set of file descriptors?

Dynasty answered 6/2, 2014 at 10:40 Comment(6)
Package java.nioRihana
Will get something here #15493772Habakkuk
I am really interested what will be the exact function in java which will do exactly as C poll.Divestiture
What makes you think there is one? There is java.nio.channels.Selector, but nobody said it was exactly the same as poll().Katalin
@EJP I'm just wondering is there, hence the "(or most similar)". Thanks, java.nio.channels.Selector looks like what I need.Dynasty
The Selector only works with network sockets and pipes, but the question is about files.Gualtiero
D
4

As @EJP has commented above for java.nio.channels.Selector

A Selector supports key-based, non-blocking, multiplexed I/O. In other words, selectors enable you to perform I/O through multiple channels. Selectors are most applicable to socket-backed channels.

It is better to take a look at javadoc for java.nio.channels.Selector.

java.nio.channels.Selector

This is available since Java ( 7 ) 1.4 and later

Divestiture answered 6/2, 2014 at 11:9 Comment(2)
The docu says Since: 1.4 – I guess its only NIO and not NIO.2Freeforall
The Selector only works with network sockets and pipes, but the question is about files.Gualtiero

© 2022 - 2024 — McMap. All rights reserved.