I am using embedded jetty and spring for java to java communication over http. My problem is that my server application must handle plain TCP messages also on the same port.
Is there a way to detect if a TCP message arrived which cannot be handled by the servlet?
Thanks for the answers I add some more details:
- I cannot modify the client. The reason for this is that the old version of the client uses pure java tcp socket and it turned out that the new server must be backward compatible with the old client.
- Have to use the same port
- Old client messages are short serialized text over simple socket. 1: open connection, 2: send text, 3: close connection
- My server looks something like this: http://kielczewski.eu/2013/11/using-embedded-jetty-spring-mvc/
- I do not need to parse the message. It is enough to detect that a message was arrived which is not using http and get the source host name.
ServerConnectorimplementation of your own to pre-parse the incoming whatever to know if its HTTP/0.9, HTTP/1.0, HTTP/1.1, HTTP/2, or Raw TCP and then call the appropriate layers in Jetty (for http) or your app (if not http). Out of curiosity, why not just use WebSocket instead? - Joakim Erdfelt