package cs522.elind.io; import java.io.*; import java.net.*; public class MonitorSocket extends Socket { protected MonitorInputStream monitorIn; protected MonitorOutputStream monitorOut; public MonitorSocket() throws IOException { super(); } public MonitorSocket(String host, int port) throws IOException { super(host, port); } public InputStream getInputStream() throws IOException { if(null == monitorIn) { InputStream original = super.getInputStream(); monitorIn = new MonitorInputStream(original); } return monitorIn; } public OutputStream getOutputStream() throws IOException { if(null == monitorOut) { OutputStream original = super.getOutputStream(); monitorOut = new MonitorOutputStream(original); } return monitorOut; } public synchronized void close() throws IOException { if(null != monitorOut) { monitorOut.flush(); monitorOut.close(); } if(null != monitorIn) { monitorIn.close(); } } }