1 24 25 package org.objectweb.dream.channel; 26 27 import java.io.IOException ; 28 import java.net.Socket ; 29 30 33 public class SocketStateImpl implements SocketState 34 { 35 protected Socket socket; 36 protected Object input; 37 protected Object output; 38 39 43 46 public void setSocket(Socket socket) 47 { 48 this.socket = socket; 49 } 50 51 54 public Object getInput() throws IOException 55 { 56 if (input == null) 57 { 58 input = socket.getInputStream(); 59 } 60 return input; 61 } 62 63 66 public void setInput(Object input) 67 { 68 this.input = input; 69 } 70 71 74 public Object getOutput() throws IOException 75 { 76 if (output == null) 77 { 78 output = socket.getOutputStream(); 79 } 80 return output; 81 } 82 83 86 public void setOutput(Object output) 87 { 88 this.output = output; 89 } 90 91 95 98 public boolean isClosed() 99 { 100 return socket.isClosed() || !socket.isConnected(); 101 } 102 103 106 public void close() 107 { 108 if (!socket.isClosed()) 109 { 110 try 111 { 112 socket.close(); 113 } 114 catch (IOException e) 115 { 116 } 118 } 119 } 120 121 125 130 public void recycle() 131 { 132 socket = null; 133 input = null; 134 output = null; 135 } 136 137 } | Popular Tags |