| 1 6 7 package com.quikj.server.log; 8 9 import java.net.*; 10 import java.io.*; 11 12 import com.quikj.server.framework.*; 13 14 18 public class ConnectionListener extends AceThread 19 { 20 private String name; 21 private ServerSocket socket; 22 private Object userParm; 23 24 25 public ConnectionListener(String name, ServerSocket socket, Object user_parm) 26 throws SocketException, IOException 27 { 28 super(name, true); 29 this.name = name; 30 userParm = user_parm; 31 this.socket = socket; 32 socket.setSoTimeout(1000); 33 } 34 35 public void dispose() 36 { 37 interrupt(); 38 39 if (socket != null) 40 { 41 try 42 { 43 socket.close(); 44 socket = null; 45 } 46 catch (IOException ex) 47 { 48 ; 49 } 50 } 51 52 super.dispose(); 53 } 54 55 public void run() 56 { 57 try 58 { 59 while (true) 60 { 61 try 62 { 63 Socket sock = socket.accept(); 64 65 LogProcessor.Instance().sendMessage(new ConnectionEvent(socket, sock, userParm)); 67 } 68 catch (InterruptedIOException ex) 69 { 70 if (isInterrupted() == true) 71 { 72 break; 73 } 74 continue; 75 } 76 } 77 } 78 catch (IOException ex) 79 { 80 dispose(); 81 } 82 } 83 } 84 | Popular Tags |