Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UpdateServer {
- /**
- * @param args
- */
- public static void main(String[] args) {
- try{
- System.out.println("Listening on port 7564....");
- ServerSocket sock = new ServerSocket(7564);
- Socket connection = sock.accept();
- BufferedReader clientIn = new BufferedReader(
- new InputStreamReader(connection.getInputStream()));
- DataOutputStream serverOut = new DataOutputStream(connection.getOutputStream());
- System.out.println("Connected to client!");
- System.out.println("Waiting for the client to send name....");
- String client = clientIn.readLine();
- boolean reply = getReplyText(client);
- serverOut.writeBytes(Boolean.toString(reply));
- sock.close();
- connection.close();
- clientIn.close();
- serverOut.close();
- main(null);
- }
- catch(IOException ex){
- }
- }
- public static boolean getReplyText(String clientName){
- if (clientName.equals("mmu")){
- return true;
- }
- if (clientName.equals("ep")){
- return false;
- }
- else {
- System.out.println("This isn't a recognized client.");
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment