1 14 15 package org.quickserver.net.server; 16 17 import java.io.*; 18 import java.net.*; 19 import org.quickserver.net.AppException; 20 import java.util.logging.*; 22 23 24 36 public class MaxClientHandler extends Thread { 37 38 39 private Socket socket; 40 41 private String message; 42 43 private OutputStream out; 44 45 private static Logger logger = Logger.getLogger( 46 MaxClientHandler.class.getName()); 47 48 55 public MaxClientHandler(Socket client, String message) { 56 super("MaxClientHandler"); 57 socket = client; 58 this.message = message; 59 } 60 61 68 public MaxClientHandler(Socket client, String message, 69 QuickServer quickServer) { 70 this(client, message); 71 logger = quickServer.getAppLogger(); 72 } 73 74 public void run() { 75 String temp = message; 76 logger.fine("Handled client " +getSocket().getInetAddress()); 77 try { 78 out = socket.getOutputStream(); 79 out.write(temp.getBytes()); 80 out.flush(); 81 out.close(); 82 } catch(javax.net.ssl.SSLException e) { 83 logger.finest("IGNORE: SSLException: " + e); 84 } catch(IOException ie) { 85 logger.finest("IOError: " + ie); 86 } catch(Exception e) { 87 logger.finest("Error: " + e); 88 } finally { 89 try { 90 if(socket!=null) { 91 socket.close(); 92 socket=null; 93 } 94 } catch (Exception re) { 95 socket=null; 96 } 97 } 98 } 99 100 104 public String toString() { 105 if(socket!=null) 106 return socket.getInetAddress().getHostName(); 107 return null; 108 } 109 110 111 public void setSocket(Socket socket) { 112 this.socket = socket; 113 } 114 115 public Socket getSocket() { 116 return socket; 117 } 118 } 119 | Popular Tags |