01: /* jcifs smb client library in Java
02: * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.knowgate.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)
32: throws IOException {
33: if (len > 0xFFFF) {
34: throw new IOException("write too large: " + len);
35: } else if (off < 4) {
36: throw new IOException(
37: "NetBIOS socket output buffer requires 4 bytes available before off");
38: }
39:
40: off -= 4;
41:
42: b[off + 0] = (byte) SessionServicePacket.SESSION_MESSAGE;
43: b[off + 1] = (byte) 0x00;
44: b[off + 2] = (byte) ((len >> 8) & 0xFF);
45: b[off + 3] = (byte) (len & 0xFF);
46:
47: out.write(b, off, 4 + len);
48: }
49: }
|