ServerMain - /* Matthew Urtnowski Matt Young D Damon...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Matthew Urtnowski Matt Young Damon Chastain D CECS 327 Lab */ * import*; import*; import java.util.ArrayList; i public class ServerMain { public static void main(String[] args) { Server s = new Server(Integer.parseInt(args[0])); } } /*This class controlls the mail server. It is designed, so that it is concurrent and non-stateful. Each session has its own process and the user must specify there username under each request*/ class Server { /*This is a constructor for the server. It continously loops accepting new connections and then passes that connection to a process with will handle that session.*/ Server(int port) { //Continously loop and accept new connections while(true) { try { //Accept and Establish Connection / // instantiates a socket for accepting connection c ServerSocket connectionSocket = new ServerSocket(port); S // wait to accept a connecion request, at which // time a data socket is created Socket dataSocket = connectionSocket.accept(); S //Pass the connection to a new thread Thread t = new Thread(new SomeThread3(dataSocket)); t.start(); } catch(Exception e) { } } } }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
/*This class is a static storage class for all the mail. All of its parts must be synchornized since the servers processes must access it concurrently.*/ class Storage { private static ArrayList<Mail> Mail = new ArrayList<Mail>(); p //Returns a mail object based on an index public static synchronized Mail get(int index) { return Mail.get(index); } //Appends a mail message to the stoarge public static synchronized void add(Mail data) { Mail.add(data); } //Returns the size of the mail array public static synchronized int size() p { return Mail.size(); r } } /*This class is an abstract data type for quickly storing and organizing a single mail message.*/
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2010 for the course CECS 328 taught by Professor Konig,v during the Spring '08 term at CSU Long Beach.

Page1 / 8

ServerMain - /* Matthew Urtnowski Matt Young D Damon...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online