Search code examples
jakarta-eetcpsocketslisten

How to create an application in Java EE which listens for an incoming request on TCP/IP socket?


I need to have a business logic running inside GlassFish 2.1 Appserver, which listens for inbound TCP connections and serves them. I feel that this kind of task is not really fit inside the appserver - maybe I should publish web service interfaces, etc, but I can't, at least not directly for the client.

The client will connect to my app via TCP, and will exchange plain-text commands and responses.

Do I need an external mediator program which translates the client TCP to rmi calls? Or does Java EE has native support for listening on sockets and doing direct I/O on them?


Solution

  • JCA 1.5 is the standard solution for this kind of tasks, but it's not the easiest part of Java EE, and you won't find tons of examples to get you started. You could have a look at lifecycle modules if you don't mind a Glassfish specific solution, and JAFS, an ftp server that can be embedded in the 'fish probably contains a lot of inspiration to get you started.