org.opengts.util
Class ServerSocketThread.ServerSessionThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.opengts.util.ServerSocketThread.ServerSessionThread
All Implemented Interfaces:
java.lang.Runnable, ServerSocketThread.SessionInfo
Enclosing class:
ServerSocketThread

public class ServerSocketThread.ServerSessionThread
extends java.lang.Thread
implements ServerSocketThread.SessionInfo

ServerSessionThread


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServerSocketThread.ServerSessionThread()
          Empty Constructor
ServerSocketThread.ServerSessionThread(org.opengts.util.ServerSocketThread.ClientSocket clientSock, boolean startThread)
          ClientSocket handler constructor
 
Method Summary
 void close()
          Close the current session
 void forceCloseTCPSession()
          Interrupt/close client session
 int getAvailableBytes()
           
 java.net.InetAddress getInetAddress()
           
 int getLocalPort()
           
 long getReadByteCount()
           
 int getRemotePort()
           
 long getSessionReceiveTime()
           
 long getSessionStartTime()
           
 long getSessionStartTimeMS()
           
 java.lang.Thread getSessionThread()
          (SessionInfo interface) returns the current thread
 long getWriteByteCount()
           
 void handleClientSession(org.opengts.util.ServerSocketThread.ClientSocket clientSock)
           
 boolean isAvailable()
           
 boolean isInputStream()
          Returns true if the current session transport is a generic InputStream
 boolean isShutdown()
           
 boolean isTCP()
          Returns true if the current session transport is TCP
 boolean isUDP()
          Returns true if the current session transport is UDP
 void run()
           
 boolean setClientIfAvailable(org.opengts.util.ServerSocketThread.ClientSocket clientSocket)
           
 void signalShutdown()
          Signal thread to shut down
 void start()
          Start Client session thread
 boolean tcpWrite(byte[] data)
           
 boolean udpWrite(byte[] data)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerSocketThread.ServerSessionThread

public ServerSocketThread.ServerSessionThread()
Empty Constructor


ServerSocketThread.ServerSessionThread

public ServerSocketThread.ServerSessionThread(org.opengts.util.ServerSocketThread.ClientSocket clientSock,
                                              boolean startThread)
ClientSocket handler constructor

Parameters:
clientSock - The ClientSocket instance
startThread - True to start this thread
Method Detail

start

public void start()
Start Client session thread

Overrides:
start in class java.lang.Thread
Throws:
java.lang.OutOfMemoryError - If unable to create new native thread.
java.lang.IllegalThreadStateException - If thread has already been started.

getSessionThread

public java.lang.Thread getSessionThread()
(SessionInfo interface) returns the current thread

Specified by:
getSessionThread in interface ServerSocketThread.SessionInfo
Returns:
the current thread

setClientIfAvailable

public boolean setClientIfAvailable(org.opengts.util.ServerSocketThread.ClientSocket clientSocket)

isAvailable

public boolean isAvailable()

getLocalPort

public int getLocalPort()
Specified by:
getLocalPort in interface ServerSocketThread.SessionInfo

getRemotePort

public int getRemotePort()
Specified by:
getRemotePort in interface ServerSocketThread.SessionInfo

isTCP

public boolean isTCP()
Returns true if the current session transport is TCP

Specified by:
isTCP in interface ServerSocketThread.SessionInfo

isUDP

public boolean isUDP()
Returns true if the current session transport is UDP

Specified by:
isUDP in interface ServerSocketThread.SessionInfo

isInputStream

public boolean isInputStream()
Returns true if the current session transport is a generic InputStream

Specified by:
isInputStream in interface ServerSocketThread.SessionInfo

getInetAddress

public java.net.InetAddress getInetAddress()
Specified by:
getInetAddress in interface ServerSocketThread.SessionInfo

getAvailableBytes

public int getAvailableBytes()
Specified by:
getAvailableBytes in interface ServerSocketThread.SessionInfo

getReadByteCount

public long getReadByteCount()
Specified by:
getReadByteCount in interface ServerSocketThread.SessionInfo

getWriteByteCount

public long getWriteByteCount()
Specified by:
getWriteByteCount in interface ServerSocketThread.SessionInfo

getSessionStartTimeMS

public long getSessionStartTimeMS()
Specified by:
getSessionStartTimeMS in interface ServerSocketThread.SessionInfo

getSessionStartTime

public long getSessionStartTime()
Specified by:
getSessionStartTime in interface ServerSocketThread.SessionInfo

getSessionReceiveTime

public long getSessionReceiveTime()
Specified by:
getSessionReceiveTime in interface ServerSocketThread.SessionInfo

tcpWrite

public boolean tcpWrite(byte[] data)
Specified by:
tcpWrite in interface ServerSocketThread.SessionInfo

udpWrite

public boolean udpWrite(byte[] data)
Specified by:
udpWrite in interface ServerSocketThread.SessionInfo

forceCloseTCPSession

public void forceCloseTCPSession()
Interrupt/close client session

Specified by:
forceCloseTCPSession in interface ServerSocketThread.SessionInfo

close

public void close()
           throws java.io.IOException
Close the current session

Throws:
java.io.IOException

signalShutdown

public void signalShutdown()
Signal thread to shut down


isShutdown

public boolean isShutdown()

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

handleClientSession

public void handleClientSession(org.opengts.util.ServerSocketThread.ClientSocket clientSock)