1 import jcifs.smb.SmbNamedPipe; 2 import java.io.InputStream ; 3 import java.io.OutputStream ; 4 import java.io.FileInputStream ; 5 import java.io.FileOutputStream ; 6 7 public class TransactNamedPipe { 8 9 public static void main( String [] argv ) throws Exception { 10 11 if( argv.length < 2 ) { 12 throw new IllegalArgumentException ( 13 "args: <smburl> <filedatatosend> <filetowriterecvdata>" ); 14 } 15 16 byte[] b = new byte[65535]; 17 FileInputStream fin = new FileInputStream ( argv[1] ); 18 FileOutputStream fos = new FileOutputStream ( argv[2] ); 19 20 SmbNamedPipe pipe = new SmbNamedPipe( argv[0], 21 SmbNamedPipe.PIPE_TYPE_RDWR | SmbNamedPipe.PIPE_TYPE_TRANSACT ); 22 OutputStream out = pipe.getNamedPipeOutputStream(); 23 InputStream in = pipe.getNamedPipeInputStream(); 24 25 int n = fin.read( b ); 26 System.out.println( "writing " + n + " bytes" ); 27 out.write( b, 0, n ); 28 n = in.read(b); 29 System.out.println( "read " + n + " bytes" ); 30 fos.write(b, 0, n ); 31 32 fin.close(); 33 fos.close(); 34 out.close(); 35 } 36 } 37 | Popular Tags |