| 1 6 7 package com.quikj.server.framework; 8 9 import java.net.*; 10 import java.io.*; 11 12 16 public class AceCommandConnectionListener extends Thread  17 { 18 private ServerSocket sock; 19 20 21 public AceCommandConnectionListener(int port) 22 throws IOException 23 { 24 sock = new ServerSocket(port); 25 } 26 27 public void dispose() 28 { 29 try 30 { 31 sock.close(); 32 } 33 catch (IOException ex) 34 { 35 ; } 37 38 interrupt(); 39 } 40 41 public void run() 42 { 43 try 44 { 45 while (isInterrupted() == false) 46 { 47 Socket session_socket = sock.accept(); 48 49 if (AceCommandService.getInstance().getCommandSessionThreadGrup().activeCount() 50 >= AceCommandService.getInstance().getMaxUsers()) 51 { 52 try 53 { 54 session_socket.close(); 55 continue; 56 } 57 catch (SocketException ex) 58 { 59 continue; 60 } 61 catch (IOException ex) 62 { 63 continue; } 65 66 } 67 68 try 69 { 70 AceCommandSession session = new AceCommandSession( 72 AceCommandService.getInstance().getCommandSessionThreadGrup(), 73 session_socket, 74 AceCommandService.getInstance().getCommandPrompt()); 75 session.start(); 76 } 77 catch (IOException ex1) 78 { 79 try 80 { 81 session_socket.close(); 82 } 83 catch (IOException ex2) 84 { 85 ; 86 } 87 continue; 88 } 89 } 90 } 91 catch (IOException ex) 92 { 93 ; 94 } 95 96 dispose(); 97 } 98 } 99 | Popular Tags |