|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
edu.jas.util.ChannelFactory
public class ChannelFactory
ChannelFactory implements a symmetric and non blocking way of setting up sockets on the client and server side. The constructor sets up a ServerSocket and accepts and stores any Socket creation requests from clients. The created Sockets can the be retrieved from the store without blocking. Refactored for java.util.concurrent.
SocketChannel
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
static int |
DEFAULT_PORT
default port of socket. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
ChannelFactory()
Constructs a ChannelFactory on the DEFAULT_PORT. |
|
ChannelFactory(int p)
Constructs a ChannelFactory. |
Method Summary | |
---|---|
SocketChannel |
getChannel()
Get a new socket channel from a server socket. |
SocketChannel |
getChannel(java.lang.String h,
int p)
Get a new socket channel to a given host. |
void |
run()
Eun the servers accept() in an infinite loop. |
void |
terminate()
Terminate the Channel Factory |
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 int DEFAULT_PORT
Constructor Detail |
---|
public ChannelFactory(int p)
p
- port.public ChannelFactory()
Method Detail |
---|
public SocketChannel getChannel() throws java.lang.InterruptedException
java.lang.InterruptedException
public SocketChannel getChannel(java.lang.String h, int p) throws java.io.IOException
java.io.IOException
h
- hostnamep
- portpublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void terminate()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |