5 Replies Latest reply on Mar 22, 2004 10:58 AM by alanc_yang

    a program in jboss that listens on a port

    alanc_yang

      I need to implement a program under jboss that would listen on a port. I am not sure it should be a service or something else. Wonder anybody can shed some lights.

      Thanks in advance.
      Alan

        • 1. Re: a program in jboss that listens on a port
          camel

          You could impmenent this as a jboss service. What is your program going to do? If it's going to be your basic request/response server (even with long-lived connections), you may be able to implement it as a servlet. Not an HttpServlet, but just a custom servlet (i.e., it implements the Servlet interface or extends javax.servlet.GenericServlet).

          Assuming you need a protocol other than HTTP, you can write a custom protocol handler ("connector" in Tomcat lingo) that reads the data, builds a ServletRequest object (not HttpServletRequest), and calls the server to map it and service it. This is how tomcat accepts JK2 requests from Apache httpd.

          I actually did this for a school project, and implemented several interesting protocol connectors and servlets, for services like DNS, SMTP, POP3, HTTP, and finger. (I didn't use tomcat; I wrote my own mini-servlet container, but you may be better off using something more tried-and-true like tomcat).

          I can dig up the source if you're interested.

          • 2. Re: a program in jboss that listens on a port
            alanc_yang

            The program would listen on the port with tcp/udp or http that it process the command to send to client and process corresponding response. If you can send your source that would be very very useful. Really appreciate.

            Alan

            • 3. Re: a program in jboss that listens on a port
              alanc_yang

              Could you please send your source to: alanc_yang@yahoo.com? Thanks again for your help.

              - Alan

              • 4. Re: a program in jboss that listens on a port
                camel

                Comin your way.

                • 5. Re: a program in jboss that listens on a port
                  alanc_yang

                  opened a DatagramSocket from within mbean service, no problem!