mobnet
Class SocketTimer

java.lang.Object
  extended byjava.lang.Thread
      extended bymobnet.SocketTimer
All Implemented Interfaces:
java.lang.Runnable

public class SocketTimer
extends java.lang.Thread

SocketTimer.java SocketTimer is used to implement timeouts when reading from a Socket

Author:
Avi TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SocketTimer(int ms, InputStream input)
          Constructor for SocketTimer
 
Method Summary
 int getTimeout()
           
static void main(java.lang.String[] args)
           
 void resetTimer()
          Reset the timer.
 void run()
          Run method to launch timer in new thread.
 void setTimer(int ms)
          Set the length of the timeout
 void startTimer()
          Start the timer.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SocketTimer

public SocketTimer(int ms,
                   InputStream input)
Constructor for SocketTimer

Parameters:
ms - Length of time out
input - InputStream to which this SocketTimer is bound to
Method Detail

startTimer

public void startTimer()
                throws java.net.SocketTimeoutException
Start the timer. Will throw a SocketTimeoutException when the timer reaches t-0.

Throws:
java.net.SocketTimeoutException

resetTimer

public void resetTimer()
Reset the timer.


setTimer

public void setTimer(int ms)
Set the length of the timeout

Parameters:
ms - length of timeout in milliseconds

getTimeout

public int getTimeout()

run

public void run()
Run method to launch timer in new thread.


main

public static void main(java.lang.String[] args)