Project JXTA

net.jxta.impl.endpoint.tls
Class JTlsOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended bynet.jxta.impl.endpoint.tls.JTlsOutputStream

class JTlsOutputStream
extends OutputStream

Acts as the output for TLS. Accepts ciphertext from TLS and packages it into messages for sending to the remote. The messages are kept in a retry queue until the remote peer acknowledges receipt of the message.


Field Summary
(package private)  List retrQ
          The collection of messages available for re-transmission.
 
Constructor Summary
(package private) JTlsOutputStream(TlsTransport tp, TlsConn conn)
           
 
Method Summary
(package private)  void ackReceived(int seqnum, int[] sackList)
          Process an ACK Message.
 void close()
          

We don't current support linger.

 void setClosing()
          indicate that we're in the process of closing.
 void write(byte[] b, int off, int len)
          

We override the write(byte[], offset, length); method which is called by SSLRecord.send(SSLConn conn) via tos.writeTo(conn.sock_out), tos a ByteArrayOutputStream which has buffered the TLS output record in the byte array.

 void write(int c)
          
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

retrQ

List retrQ
The collection of messages available for re-transmission. elements are RetrQElt

Constructor Detail

JTlsOutputStream

JTlsOutputStream(TlsTransport tp,
                 TlsConn conn)
Method Detail

close

public void close()
           throws IOException

We don't current support linger.

Throws:
IOException

setClosing

public void setClosing()
indicate that we're in the process of closing. To respect the semantics of close()/isClosed(), we do not set the closed flag, yet. Instead, we set the flag "closing", which simply garantees that no new message will be queued. This, in combination with getSequenceNumber and getMaxAck, and waitQevent, enables fine grain control of the tear down process.


write

public void write(int c)
           throws IOException

Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException

We override the write(byte[], offset, length); method which is called by SSLRecord.send(SSLConn conn) via tos.writeTo(conn.sock_out), tos a ByteArrayOutputStream which has buffered the TLS output record in the byte array. The actual call is write(byte[] b, 0, length);

We put this TLS record into a msssage element for the output pipe to send along.

This is reasonable since in fact, if more than 16K bytes of application data are sent, then the max TLS Record is a little larger than 16K bytes including the TLS overhead.

Therefore, an app. message is N+r TLS Records, Message length = Nx16K + r, N >= 0, r >= 0, N > 0 || r > 0 true.

Throws:
IOException

ackReceived

void ackReceived(int seqnum,
                 int[] sackList)
Process an ACK Message. We remove ACKed messages from the retry queue. We only acknowledge messages received in sequence. The seqnum is for the largest unacknowledged seqnum the receipient has received. The sackList is a sequence of all of the received messages in the sender's input Q. All will be sequence numbers higher than the sequential ACK seqnum. Recepients are passive and only ack upon the receipt of an in sequence message. They depend on our RTO to fill holes in message sequences.


JXTA J2SE