SocketChannel.read() == -1

I have created a server thread and a client thread which communicate with each other through a loopback connection. The client is writing to the server.

The server uses an existing address: 192.168.179.11:1234 and the client uses: 127.0.0.1:random open port

When I print out the connection status (toString() ) I can see that it really is connected. When I try to read from the stream, I get a -1 as a read result.
The problem is that the channel is immediately selected again by the Selector of the server, ( I never remove the OP_READ flag ) and this is basically causing an endless loop.

I thought the client side of the channel was to blame, as if it is constantly writing again and again, but it doesn’t seem to be. I only see 1 printout from the method that calls write().

I wanted to capture the data with Ethereal, but that doesn’t work on Windows with the loopback device. :-/

So, until I can help myself with getting the facts straight ::slight_smile: I would like to know whether this seems to be some kind of newbie nio error.

Must have been, I have added lots of improvements to the debugging messages and shoved a few things around after that and presto!

For what its worth, the connection was connected on the server side, when I printed it out, but still connection pending on the client side. The server registered the channel with reading but failed to read anything from it, naturally, since that was STILL impossible.