|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread networking.base.ForkedThread networking.base.SocketThread
public abstract class SocketThread
SocketThread - this class represents a thread which owns a socket and maintains an additional message queue
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private boolean |
m_exit
Exit flag |
private java.io.InputStream |
m_in
Input socket stream |
private java.io.PipedInputStream |
m_innerIn
Input stream for internal queue processing |
private java.io.PipedOutputStream |
m_innerOut
Output stream for internal queue processing |
private java.io.OutputStream |
m_out
Output socket stream |
private java.net.Socket |
m_socket
Socket |
private long |
m_timeOut
Maximum idle time (milliseconds) after which the thread exits |
static long |
s_timeSleep
Sleep value used in wait message loop (milliseconds) |
Fields inherited from class networking.base.ForkedThread |
---|
CHILD, m_fork, NONE, PARENT |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
SocketThread()
Construct new SocketThread object |
|
SocketThread(java.net.Socket socket)
Construct new SocketThread object |
|
SocketThread(SocketThread t)
Copy constructor |
Method Summary | |
---|---|
protected void |
deinit()
Deallocate resources |
void |
enque(Message msg)
|
protected abstract void |
error(java.lang.Exception e)
Report error |
protected void |
exit()
Exit message loop |
protected java.io.InputStream |
getIn()
Get socket input stream |
protected java.io.OutputStream |
getOut()
Get socket output stream |
protected void |
init()
Allocate any required resources |
private void |
init1()
Init inner queue |
protected void |
processMessage(Message msg)
Process a message |
protected Message |
recv()
|
protected void |
run1()
Convenience routine |
protected void |
send(Message msg)
|
protected void |
setSocket(java.net.Socket socket)
Attach socket after construction |
void |
setTimeOut(long millis)
Set time-out value |
protected void |
wait(java.io.InputStream in)
Wait for InputStream become ready for reading, or exit was called or time-out has expired |
private java.io.InputStream |
waitOneOf()
Wait for one of the InputStreams become ready for reading, or exit was called or time-out has expired |
Methods inherited from class networking.base.ForkedThread |
---|
run |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final long s_timeSleep
private java.net.Socket m_socket
private java.io.OutputStream m_out
private java.io.InputStream m_in
private java.io.PipedOutputStream m_innerOut
private java.io.PipedInputStream m_innerIn
private boolean m_exit
private long m_timeOut
Constructor Detail |
---|
public SocketThread()
public SocketThread(java.net.Socket socket)
socket
- socketpublic SocketThread(SocketThread t)
st
- SocketThread objectMethod Detail |
---|
protected void setSocket(java.net.Socket socket)
socket
- socketprotected void processMessage(Message msg) throws java.lang.Exception
msg
- message
java.lang.Exception
protected final void exit()
public final void setTimeOut(long millis)
millis
- time-out value (milliseconds)protected final void wait(java.io.InputStream in) throws java.lang.Exception
in
- InputStream
java.lang.Exception
private java.io.InputStream waitOneOf() throws java.lang.Exception
java.lang.Exception
protected void run1() throws java.lang.Exception
run1
in class ForkedThread
java.lang.Exception
private void init1() throws java.lang.Exception
java.lang.Exception
protected void init() throws java.lang.Exception
ForkedThread
init
in class ForkedThread
java.lang.Exception
protected void deinit() throws java.lang.Exception
ForkedThread
deinit
in class ForkedThread
java.lang.Exception
public final void enque(Message msg) throws java.lang.Exception
java.lang.Exception
protected final void send(Message msg) throws java.lang.Exception
java.lang.Exception
protected final Message recv() throws java.lang.Exception
java.lang.Exception
protected final java.io.OutputStream getOut()
protected final java.io.InputStream getIn()
protected abstract void error(java.lang.Exception e)
error
in class ForkedThread
e
- exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2009 Alexey Veremenko. All rights reserved.