The classes
public class PortInputStream extends InputStream {
// Constructor.
public PortInputStream(Port P) ;
// Methods.
public synchronized int read() ;
public synchronized int read(byte b [], int off, int len) ;
[etc...]
}
and
public class PortOutputStream extends OutputStream {
Port P ;
ByteArrayOutputStream strm ;
// Constructor.
public PortOutputStream(Port P) ;
// Methods.
public synchronized void write(int b) ;
public synchronized void write(byte b [], int off, int len) ;
public synchronized void flush() ;
}
provide a convenient interface for Java I/O on ports. DataInputStream
and DataOutputStream wrappers can be created around these streams,
making the standard Java read and write operations available.
A PortOutputStream buffers data written to it until a flush operation is performed. At this point a send operation on the Port is executed and the buffered data is output as a single message.
A PortInputStream contains a buffer which is replenished by executing a recv on the Port whenever the buffer is empty and a a read operation is performed on the stream.