1 7 package org.jboss.remoting.transport.socket; 8 9 import java.io.BufferedInputStream ; 10 import java.io.BufferedOutputStream ; 11 import java.io.IOException ; 12 import java.io.InputStream ; 13 import java.io.ObjectInputStream ; 14 import java.io.ObjectOutputStream ; 15 import java.io.OutputStream ; 16 import java.net.Socket ; 17 import org.jboss.remoting.loading.ObjectInputStreamWithClassLoader; 18 19 22 public class ClientSocketWrapper extends SocketWrapper 23 { 24 private ObjectInputStream in; 25 private ObjectOutputStream out; 26 27 public ClientSocketWrapper(Socket socket) throws Exception 28 { 29 super(socket); 30 31 out = createOutputStream(socket); 32 in = createInputStream(socket); 33 } 34 35 protected ObjectInputStream createInputStream(Socket socket) 36 throws IOException 37 { 38 BufferedInputStream bin = new BufferedInputStream (socket.getInputStream()); 39 ObjectInputStream oin = new ObjectInputStreamWithClassLoader(bin, null); 41 return oin; 42 } 43 44 protected ObjectOutputStream createOutputStream(Socket socket) 45 throws IOException 46 { 47 BufferedOutputStream bout = new BufferedOutputStream (socket.getOutputStream()); 48 ObjectOutputStream oout = new ObjectOutputStream (bout); 49 return oout; 50 } 51 52 public OutputStream getOutputStream() 53 { 54 return out; 55 } 56 57 public InputStream getInputStream() 58 { 59 return in; 60 } 61 62 public void checkConnection() throws IOException 63 { 64 final byte ACK = 1; 66 67 out.reset(); 68 out.writeByte(ACK); 69 out.flush(); 70 in.readByte(); 71 72 } 73 } 74 75 | Popular Tags |