Non-http tcp protocol
Hi all, I'm trying to figure out how to use tomcat as a TCP server. The basic idea is to receive tcp connections, through a given port, process them and return a response. Has anyone done it? I've googling but I've not found much information. Which do you think is the best/simplest way to do it? Thanks a lot - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Non-http tcp protocol
hello, take the simpliest example from a java book. this is one: public class BasicTCPServer extends AbstractServer implements Runnable{ /** * The port to listen on. */ private int port; /** * The listening socket. */ private ServerSocket serverSocket; /** * True as long as we are running. */ private volatile boolean running; /** * Creates a new server with the given port and connection factory. * @param aPort the port to listen to. * @param conFactory */ public BasicTCPServer(int aPort, IConnectionFactory conFactory){ super(conFactory); port = aPort; } @Override public void startServer() throws ServerException{ try{ serverSocket = new ServerSocket(port); }catch(IOException e){ throw new ServerException(Couldn't bind port: +port+ : +e.getMessage()); } new Thread(this).start(); } @Override public void run(){ setRunning(true); while(isRunning()){ try{ Socket s = serverSocket.accept(); IConnection newConnection = getConnectionFactory().createConnection(new SocketContext(s)); notifyConnectionCreated(newConnection); newConnection.open(); }catch(IOException e){ e.printStackTrace(); } } } /** * Stops the server. */ @Override public void stopServer() { setRunning(false); } regards Leon P.S. you can checkout the code under svn://svn.anotheria.net/opensource/ano-net/trunk with a ready to use tcp client/server, udp client/server and so on. On Mon, Sep 28, 2009 at 10:10 AM, Sergio Bello ser...@televes.com wrote: Hi all, I'm trying to figure out how to use tomcat as a TCP server. The basic idea is to receive tcp connections, through a given port, process them and return a response. Has anyone done it? I've googling but I've not found much information. Which do you think is the best/simplest way to do it? Thanks a lot - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Non-http tcp protocol
Don't - there are other apache projects which can do that much better than Tomcat. -Tim Sergio Bello wrote: Hi all, I'm trying to figure out how to use tomcat as a TCP server. The basic idea is to receive tcp connections, through a given port, process them and return a response. Has anyone done it? I've googling but I've not found much information. Which do you think is the best/simplest way to do it? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Non-http tcp protocol
Tim Funk escribió: Don't - there are other apache projects which can do that much better than Tomcat. -Tim Sergio Bello wrote: Hi all, I'm trying to figure out how to use tomcat as a TCP server. The basic idea is to receive tcp connections, through a given port, process them and return a response. Has anyone done it? I've googling but I've not found much information. Which do you think is the best/simplest way to do it? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org I was thinking on tomcat to take advantage of several features (request and thread management, etc) that I know have been tested for years, but I'm not tied to the use of tomcat. If you know another project (java/opensource) I can rely on, could you tell me its name, please? - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Non-http tcp protocol
I was thinking on tomcat to take advantage of several features (request and thread management, etc) that I know have been tested for years, but I'm not tied to the use of tomcat. If you know another project (java/opensource) I can rely on, could you tell me its name, please? If you prefer Java, Apache MINA, for instance http://mina.apache.org/ Greetings from Hamburg, Stefan - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org