workspace
Class NetworkConnection

java.lang.Object
  extended by java.lang.Thread
      extended by workspace.NetworkConnection
All Implemented Interfaces:
java.lang.Runnable

public class NetworkConnection
extends java.lang.Thread

This class encapsulates the connections to another host. All events received are passed on to a queue, which another thread is expected to process.


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
NetworkConnection(NetworkManager manager, java.lang.Long id, java.net.Socket s, java.util.Queue<NetworkEvent> q)
           
 
Method Summary
 void close()
          Close the streams and the socket.
 java.lang.String getHostAddress()
           
 int getPort()
           
 void run()
          Continually read from the input stream.
 java.lang.String toString()
           
 void write(NetworkEvent event)
          Write to the output stream.
 
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, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NetworkConnection

public NetworkConnection(NetworkManager manager,
                         java.lang.Long id,
                         java.net.Socket s,
                         java.util.Queue<NetworkEvent> q)
                  throws java.io.IOException
Throws:
java.io.IOException
Method Detail

run

public void run()
Continually read from the input stream.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

write

public void write(NetworkEvent event)
           throws java.io.IOException
Write to the output stream.

Throws:
java.io.IOException

close

public void close()
Close the streams and the socket.


getHostAddress

public java.lang.String getHostAddress()

getPort

public int getPort()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Thread