Created
April 14, 2015 15:33
-
-
Save pumpkincouture/23e3ba72962095c669fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ServerMain { | |
static public void main (String args[]) throws IOException { | |
try { | |
ServerSocket server = new ServerSocket(5000); | |
while (true) { | |
Socket clientSocket = server.accept(); | |
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true); | |
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); | |
RequestParser requestParser = new RequestParser(in.readLine()); | |
Request request = new Request(requestParser.getAllRequestAttributes()); | |
ManagerFactory managerFactory = new ManagerFactory(request); | |
out.flush(); | |
out.write(managerFactory.createMethodHandler().handle(request)); | |
out.flush(); | |
in.close(); | |
} | |
} | |
catch (Exception err) { | |
System.out.println(err); | |
err.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment