1 18 19 package jcifs.netbios; 20 21 import java.io.FilterOutputStream ; 22 import java.io.OutputStream ; 23 import java.io.IOException ; 24 25 class SocketOutputStream extends FilterOutputStream { 26 27 SocketOutputStream( OutputStream out ) { 28 super( out ); 29 } 30 31 public synchronized void write( byte[] b, int off, int len ) throws IOException { 32 if( len > 0xFFFF ) { 33 throw new IOException ( "write too large: " + len ); 34 } else if( off < 4 ) { 35 throw new IOException ( "NetBIOS socket output buffer requires 4 bytes available before off" ); 36 } 37 38 off -= 4; 39 40 b[off + 0] = (byte)SessionServicePacket.SESSION_MESSAGE; 41 b[off + 1] = (byte)0x00; 42 b[off + 2] = (byte)(( len >> 8 ) & 0xFF ); 43 b[off + 3] = (byte)( len & 0xFF ); 44 45 out.write( b, off, 4 + len ); 46 } 47 } 48 | Popular Tags |