Java TCP server program running on Apache Tomcat Java TCP server program running on Apache Tomcat apache apache

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.

  1. Created a servlet
  2. 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:

  1. JCA (Java Connector Architecture) see http://code.google.com/p/jca-sockets/ for a example

  2. The JBOSS Netty Project

I recently create a tcp/ip server in Apache Camel and it was very easy.