tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From netfo...@uw.hu
Subject A Tomcat 6 Socket Server
Date Sun, 19 Jun 2011 08:06:55 GMT
To whom is reading this mail.

Hello,

For some time i have been learning some server technologies for my own  
needs. I have tried PHP but the way its constructed or the way it  
handles scripts for object oriented programing wasn't suitable for me.  
Java is more the way i think of programing and that is why i thought  
to give a try on Tomcat.

I have looked for books. Most or all of them covers only JSP, JSF or  
JDBC but non of them covers TCP - socket communication in details such  
as the ServerSocketFactory, the JSSEFactory or the ThreadPool. I could  
mention some more issues when setting up a socket based application  
like SocketPermision.

I wrote this mail in hope for answers, guidance or best practice for  
writing a Socket based application server for handling ByteArray  
communication.

Where can i get the knowlage? How can i get smarter?

Thank you in advence,
Herendi Kristóf Pál
Budapest, Hungary - 2011 June the 11th.

ps:

To give you some idea of what i was try to accomplish, here is a  
pseudo code for a Java Socket Server:

// ServerMain.java
package Server;

import java.net.ServerSocket;
import java.net.Socket;

public class ServerMain {
     private NewConnections newConn;
     private LogedInUsers ConnMemb;
     private UserList userList;
     private CommunicationGroups ComGroups;


     public ServerMain(){
         userList = new UserList();
         ConnMemb = new LogedInUsers();
         newConn = new NewConnections();
         ComGroups = new CommunicationGroups();
         try{

             ServerSocket serevrSock = new ServerSocket(4444);
             Socket clientSocket;
             while(true){
             System.out.println("Server ready, waiting for a client...");
             clientSocket = serevrSock.accept();
             new ConnectionHandler(clientSocket, userList, newConn,  
ConnMemb, ComGroups).start(); // extends Thread
             }
         }catch(Exception e){
             System.out.println("Server startUp error: "+e);
         }
     }
     public static void main(String args[]){
         new ServerMain();
     }
}

// ### END

Its simple.
I have spent some time to try to translate it for Tomcat but with out  
any refference i couldnt find the way to make it work.

If you would like to see the Tomcat version i would be happy to post  
it, but before i would like to see an experts "best practice", if i  
can have :)


-------------------------------------------------
   Externet Webmail: http://webmail.externet.hu



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message