Outpublic class Out extends OutputStream This class is a subclass of OutputStream and is used for
writing data to an SSL connection.
|
Fields Summary |
---|
private static final int | MAX_RECORD_SIZEThe maximum SSL record size to write, currently 2048.
RFC 2246 specifies it can be up to 2^14 + 2048, however
breaking up streams into smaller chunks make more sense, lower
memory usage for small devices and interspacing encryption and
network writes may work better on congested wireless networks. | private boolean | isClosedIndicates the output stream is closed. | private Record | recUnderlying SSL record layer to which bytes are written. | private SSLStreamConnection | sscHandle to current SSL stream connection. | private byte[] | bufA reusable buffer for the write method. |
Methods Summary |
---|
public synchronized void | close()Close the stream connection.
if (isClosed) {
return;
}
isClosed = true;
if (ssc != null) {
ssc.outputStreamState = SSLStreamConnection.CLOSED;
rec.closeOutputStream();
ssc.cleanupIfNeeded();
}
| public void | write(int b)Writes the specified byte to this output stream.
buf[0] = (byte) b;
write(buf, 0, 1);
| public void | write(byte[] b)Writes all the bytes in the specified byte array to this
output stream. This is equivalent to write(b, 0, b.length).
write(b, 0, b.length);
| public void | write(byte[] b, int off, int len)Writes len bytes starting at offset
off from byte array b to this
output stream.
if (isClosed) {
throw new InterruptedIOException("Stream closed");
}
synchronized(rec) {
int bytesToWrite = MAX_RECORD_SIZE;
while (len > 0) {
if (len < bytesToWrite) {
bytesToWrite = len;
}
rec.wrRec(Record.APP, b, off, bytesToWrite);
len -= bytesToWrite;
off += bytesToWrite;
}
}
|
|