Exception from deep NIO

Hi folks!

I receive an exception from deep out of the NIO stuff.
Anything against that? Maybe there is a possibility to check how much can be written w/o this to occur?

This happens although not very much is actually written, so nothing is flooded or so… Only 1-2 small messages (~100byte) per second.


java.nio.BufferOverflowException
      at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:298)
      at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:277)
      at sun.nio.ch.IOUtil.write(IOUtil.java:69)
      at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:300)
      at de.hardcode.hq.objectbus.NetLine.sendBus(NetLine.java:152)
      at de.hardcode.hq.objectbus.LocalStation.flush(LocalStation.java:232)

Are all those little messages building up without you clear() or rewind()ing?

You should be able to check the buffer has enough space via a combination of capacity(), position(), limit() and remaining(), depending on the way you want to use it.

MY buffers are OK. Otherwise the exception would occur in my code. The perfect buffer gets written to a socket, and somewhere down there a problem occurs…

I’d like to know what COULD be the reasons. Are there socket limits that have to be cared for?