Java Selector returns SelectionKey with OP_READ without data in infinity loop after writing to channel
问题 I've trouble with my code: i've written simple SocketChannel client with Selector, after starting it successfully reads messages from server (server sends events). But after writing to socket (see main method) selector starts returning readable socket in infinyty loop, handleKey returns that -1 bytes readed, so selector all time returns OP_READ SelectionKey without data for reading. Sorry for my English. Thanks. import java.io.BufferedReader; import java.io.IOException; import java.io