My company has created a java server application for use with our custom client. This server works by opening a ServerSocket on a given port and waiting for a socket connection over TCP/IP from the client. Once connected, the client and server communicate over a custom protocol which we have created.
For business reasons, we are considering doing the next revision of this server using the J2EE architecture. What I'm having difficulty figuring out is how, under J2EE, i can make the socket connection transparent to the client. Our client expects to connect to a specific port on a specific hostname. Is it possible to do this in J2EE?
What is the best way to do it?
Thanks in advance,
- ServerSockets to EJBs??? by Filip Hanik on November 02 2000 13:34 EST
- ServerSockets to EJBs??? by Surapong Kanoktipstharporn on November 02 2000 14:33 EST
- ServerSockets to EJBs??? by Dave Wolf on November 03 2000 13:12 EST
Remember that J2EE still runs in a regular Java VM, anything you did in your old app will work under J2EE without changing the code.
However, the reason that J2EE was developed was so that developers wouldn't have to create propriatery protocols and deal with low level coding such as transactions, connection pooling, sockets, comm protocols, etc.
In your new app you would replace the server socket with an EJB and on your client you wouldn't connect using a socket, instead you would use whatever protocol your EJB vendor has implement for the communication between EJB client and server.
Thanks for the reply.
I understand all of this, but my particular problem
is that i need to be able to support our current
TCP based protocol. To do this, i will probably
need to get access to the input and output streams
of the socket. It looks like i can do this by
extending the GenericServlet class to support my
protocol (rather than Http, for example). But to
do this, i need to figure out how to get the servlet
to respond to a hostname:port type connection. Most
servlet engines seem to only support some sort of
explicit servlet naming scheme (ie http://myserver:myport/myservlet) and not a direct
connection to a servlet.
or maybe there is some other way to do this using
standard J2EE/EJB means??
an even better example would be how would you design an smtp server which runs in a j2ee environment (listen on port 30, non-http protocol)? could you use a servlet to
This may be premature but ejb 2.0 has ejb's that respond to JMS messages.
Accordint to the EJB 1.1 spec section 18.1.2 components may NOT listen on server sockets.
You're best solution is to create a small standalone server that accepts the proprietary TCP sockets, translates them to another allowed protocol, and then calls the J2EE server.
Internet Applications Division