public class TCPInputStream extends InputStream
Modifier and Type | Field and Description |
---|---|
private byte[] |
b
The byte array with one element which is used by the
implementation of
read() in order to delegate to the
implementation of read(byte[], int, int) for the purposes of
simplicity. |
private static int |
DEFAULT_RECEIVE_BUFFER_SIZE
The default size of the receive buffer of TCPInputStream if the
associated MultiplexingSocket does not specify a value.
|
private boolean |
inRead
The indicator which determines whether this TCPInputStream is
executing one of its read method implementations.
|
private DatagramPacket |
packet
Current packet being processed if any.
|
private byte[] |
packetData
The data of
packet . |
private int |
packetLength
Current packet length.
|
private int |
packetOffset
Current offset.
|
private Object |
readSyncRoot
The Object which synchronizes the access to the read-related
state of this instance.
|
private MultiplexingSocket |
socket
The MultiplexingSocket which has initialized this instance and
is using it as its inputStream.
|
Constructor and Description |
---|
TCPInputStream(MultiplexingSocket socket)
Initializes a new TCPInputStream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
protected int |
read0(byte[] b,
int off,
int len) |
long |
skip(long n) |
private void |
waitWhileInRead()
Waits on
readSyncRoot while inRead equals
true. |
available, mark, markSupported, read, reset
private static final int DEFAULT_RECEIVE_BUFFER_SIZE
private final byte[] b
read()
in order to delegate to the
implementation of read(byte[], int, int)
for the purposes of
simplicity.private boolean inRead
private DatagramPacket packet
private byte[] packetData
packet
.private int packetLength
private int packetOffset
private final Object readSyncRoot
private final MultiplexingSocket socket
public TCPInputStream(MultiplexingSocket socket)
socket
- The inputStream for this instance.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
protected int read0(byte[] b, int off, int len) throws IOException
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
private void waitWhileInRead()
readSyncRoot
while inRead
equals
true.Copyright © 2018. All rights reserved.