It's a difficult problem.
- If you set OOB inlining to
false
, you lose the notification.
- If you set OOB inlining to
true
, they potentially get injected in the middle of something else.
One possible solution is a lead provided by this answer:
Apparently, the Tomcat 6.0 codebase has a JNI implementation of sockets that handles OOB differently. It looks like you could use atMark(...)
to test whether the socket has just received an OOB marker.
UPDATE - After reviewing the telnet protocol spec, it seems that the effect of losing the OOB notification would not be a show-stopper. Telnet's "synch" mechanism entails sending an OOB notification, and adding a "DATA MARK" command to the regular stream. It tells the receiving end that it can throw away data (but not telnet commands) until it sees the "DATA MARK".
If the receiving end misses (or ignores) the OOB marker, then the net effect is that it doesn't ignore the data. That is "mostly harmless" behaviour. Not ideal ... but it doesn't stop telnet from working.
Fortunately (as @EJP noted) the TCP OOB notification mechanism is rarely used these days. So Java's limited support for it hardly matters.
It is also worth noting that handling OOB notifications is not just a Java problem. Apparently, different implementations of the (native / C) socket APIs handle it in incompatible ways.
The best advice is to avoid OOB entirely if possible. Certainly don't design it into new protocols.