Skip to content

Instantly share code, notes, and snippets.

@pumpkincouture
Created April 14, 2015 15:33
Show Gist options
  • Save pumpkincouture/23e3ba72962095c669fc to your computer and use it in GitHub Desktop.
Save pumpkincouture/23e3ba72962095c669fc to your computer and use it in GitHub Desktop.
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