Java TCP server program running on Apache Tomcat
We did this successfully for a chat program a couple of years ago but it was a nightmare to maintain. There are several other more standardised ways of doing this. From the top of my head here is what we did.
- Created a servlet
- In the servlet init function created a thread that services the socket.
You can see a example of this here Connecting to socket on Tomcat?. Also read this discussion How to listen a socket in Tomcat(servlet container)?
Some alternatives would be to google the following:
JCA (Java Connector Architecture) see http://code.google.com/p/jca-sockets/ for a example
The JBOSS Netty Project
I recently create a tcp/ip server in Apache Camel and it was very easy.