• Post Reply Bookmark Topic Watch Topic
  • New Topic

epoll in Java?

 
Dima Freit
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Linux there's the facility epoll which allows a thread to react to any of a number of heterogenous events. The events can be custom defined. If I want to have a thread that can react to either a socket event or an input from the console, I can implement this via epoll.

Is there something similar in Java? I was looking at the nio package and that lets my thread to select on a number of sockets. However, there does not seem to be a way to register console/standard io with a selector. Do I not see something? Is there another facility that lets me do this?

Thanks.
df
 
Henry Wong
author
Sheriff
Posts: 22542
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Moving topic to I/O forum, as it is more related to that than to threads.

Henry
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder why you would have to have a non blocking I/O or an event based server handler for a console as there will only be one client for this server side handler.
I can understand if you are re-directing multiple console inputs to a single server socket but in a scenario where there is one console to one server handler mapping, I am unable to understand the reasoning for an event based server.
If you are trying to have a single server processing model for both console & other socket input then I would say it is not worth in this usecase. After all there are many valid scenarios for blocking I/O anyways. NIO is not a replacement for blocking I/O

Anyways, java does not support registering an arbitrary stream to a selector. It has to be an implementation of a SelectableChannel which the InputStrem (System.in) does not implement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!