views:

356

answers:

2

Does anybody know how to receive (how to know that you received) out-of-band data with Java sockets? In particular I've read the documentation for sendUrgentData and setOOBInline which states that:

Note, only limited support is provided for handling incoming urgent data. In particular, no notification of incoming urgent data is provided and there is no capability to distinguish between normal data and urgent data unless provided by a higher level protocol.

But I'm still hoping that somebody has a solution :-)

More details:

I'm sending serialized objects trough the socket and I'm not really seeing how I can find a "random" OOB byte inserted in the stream (other than the fact that Java will give me an exception when I'll try to deserialize the object).

+1  A: 

It looks like Java, up to Java 6 (I didn't investigate Java 7 since I don't know if they've decided for sure what will go in or not) and it looks like Java does not provide any support at all for reading urgent TCP information in an out-of-band manner. And it looks like this is a deliberate choice, thus far.

However, I did find one user who implemented his own solution, using JNI, to successfully read urgent data out of stream. This hack is very old and may or may not work on recent JDK's. I have not tried this myself! Your milage may vary. :) But hopefully this will help you.

Eddie
+1  A: 

Tomcat has a maintained implementation of JNI socket which can read urgent packets in a OOB manner.

kataru
Thanks, this is a great tip. Being maintained by Tomcat means that I don't have to worry that much about it being unsupported in the future. The link btw is: http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/tomcat/jni/Socket.html#atmark%28long%29
Cd-MaN