|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--edu.virginia.cs.mng.hypercast.IncomingSocketObject
This object manages an incoming socket connection. It provides synchronization for multiple threads receive()ing. It will also interrupt and receive()ing thread when the object is close()d.
This object manages a buffer of TCP_UnicastAdapter.RECEIVE_BUFFER_SIZE. It is a limit on the maximum size of a message.
This thread calls the createMessage() function of the I_AdapterCallBack implementer.
| Field Summary | |
(package private) I_AdapterCallBack |
callback
The object implementing the createMessage() function. |
(package private) int |
endValidBytes
One beyond the index of the final byte in receiveBuffer
that was read from the InputStream. |
(package private) boolean |
inCallBack
True while the synchronized thread is inside an I_AdapterCallBack function. |
(package private) java.io.InputStream |
is
The InputStream of the socket. |
(package private) boolean |
isClosed
True if the socket has been closed. |
(package private) long |
lastTimeAttemptToRead
Ideally, the last time a thread performed the read() call to the InputStream. |
(package private) long |
lastTimeRead
Ideally, the last time a thread returned from the read() call to the InputStream. |
(package private) TCP_UnicastAdapter |
parent
The TCP_UnicastAdapter that created this object. |
(package private) byte[] |
receiveBuffer
The buffer for holding data read from the InputStream. |
(package private) java.net.Socket |
s
The socket. |
(package private) int[] |
startValidBytes
startValidBytes[0] holds the location in receiveBuffer
of first byte read from the InputStream. |
(package private) java.lang.Thread |
waitingThread
The thread currently reading from the InputStream. |
(package private) java.lang.Object |
waitingThreadGuard
A lock. |
| Constructor Summary | |
(package private) |
IncomingSocketObject(java.net.Socket sock,
I_AdapterCallBack cb,
TCP_UnicastAdapter p)
|
| Method Summary | |
(package private) void |
close()
Closes the socket and interrupts any thread currently read()ing. |
(package private) boolean |
dataWaiting()
Returns true if data is in buffer or InputStream has bytes available. |
(package private) boolean |
isClosed()
Returns true if the thread will never call an function in I_AdapterCallBack again. |
(package private) boolean |
noAttemptToReadInTime(int timePeriod,
long currentTime)
Returns true if there a read call has not been made in the last timePeriod milliseconds. |
(package private) boolean |
noReadInTime(int timePeriod,
long currentTime)
Returns true if there a read has not completed in the last timePeriod milliseconds. |
private void |
readBytes()
Private function that adds bytes to the buffer from the InputStream. |
I_Message |
receive()
Returns a new message as gotten from I_AdapterCallBack.createMessage. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
java.net.Socket s
java.io.InputStream is
I_AdapterCallBack callback
TCP_UnicastAdapter parent
byte[] receiveBuffer
receiveBuffer[startValidBytes[0]] to
receiveBuffer[endValidBytes-1]int[] startValidBytes
receiveBuffer
of first byte read from the InputStream.
startValidBytes is an array of length 1.I_AdapterCallBack#createMessageint endValidBytes
receiveBuffer
that was read from the InputStream.java.lang.Thread waitingThread
java.lang.Object waitingThreadGuard
waitingThread
while it is reading from the InputStream.boolean isClosed
boolean inCallBack
long lastTimeAttemptToRead
long lastTimeRead
| Constructor Detail |
IncomingSocketObject(java.net.Socket sock,
I_AdapterCallBack cb,
TCP_UnicastAdapter p)
throws java.io.IOException
| Method Detail |
boolean noReadInTime(int timePeriod,
long currentTime)
timePeriod milliseconds.
boolean noAttemptToReadInTime(int timePeriod,
long currentTime)
timePeriod milliseconds.boolean dataWaiting()
void close()
boolean isClosed()
private void readBytes()
throws java.io.IOException
public I_Message receive()
throws java.io.IOException
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||