0

I understand a channel.write(outBuffer) can fail to write all the contents of outBuffer because the underlying socket buffer is full. Then you have to register OP_WRITE and wait for selector callbacks. However I don't want to write a partial message and I would like to wait until the channel.write operation is capable of writing out my full message. Is that possible or I have to write to find out how much I can write?


Talking about a http://docs.oracle.com/javase/6/docs/api/java/nio/channels/WritableByteChannel.html of course.

Andy Thomas
  • 84,978
  • 11
  • 107
  • 151
chrisapotek
  • 6,007
  • 14
  • 51
  • 85
  • What kind of channel are you talking about? Channel itself only has `isOpen` and `close` methods: http://docs.oracle.com/javase/6/docs/api/ – Lucas Apr 29 '13 at 15:24
  • @chrisapotek - Since NIO is used in Java to refer to the "New IO" packages in java.nio, changed the title to "non-blocking IO", per your comments in my answer, which I'm now deleting. – Andy Thomas Apr 29 '13 at 16:18

1 Answers1

0

Don't worry about it. There is no such thing as a 'message' in TCP. TCP may break your write up any way it likes, and the receiver may receive it in one read or N or anything in between.

user207421
  • 305,947
  • 44
  • 307
  • 483