Java sockets with out of band data

痞子三分冷 提交于 2020-01-01 11:57:30

问题


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:


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




回答2:


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.



来源:https://stackoverflow.com/questions/535820/java-sockets-with-out-of-band-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!