Class ChannelFactory
java.lang.Object
java.lang.Thread
edu.jas.util.ChannelFactory
- All Implemented Interfaces:
Runnable
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.
- Author:
- Akitoshi Yoshida, Heinz Kredel
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a ChannelFactory on the DEFAULT_PORT.ChannelFactory(int p) Constructs a ChannelFactory. -
Method Summary
Modifier and TypeMethodDescriptionGet a new socket channel from a server socket.getChannel(String h) Get a new socket channel to a given host.getChannel(String h, int p) Get a new socket channel to a given host.voidinit()thread initialization and start.voidrun()Run the servers accept() in an infinite loop.voidTerminate the Channel FactorytoString()toString.Methods inherited from class 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, start, stop, stop, suspend, yield
-
Field Details
-
DEFAULT_PORT
public static final int DEFAULT_PORTdefault port of socket.- See Also:
-
-
Constructor Details
-
ChannelFactory
public ChannelFactory()Constructs a ChannelFactory on the DEFAULT_PORT. -
ChannelFactory
public ChannelFactory(int p) Constructs a ChannelFactory.- Parameters:
p- port.
-
-
Method Details
-
toString
-
init
public void init()thread initialization and start. -
getChannel
Get a new socket channel from a server socket.- Throws:
InterruptedException
-
getChannel
Get a new socket channel to a given host.- Parameters:
h- hostname- Throws:
IOException
-
getChannel
Get a new socket channel to a given host.- Parameters:
h- hostnamep- port- Throws:
IOException
-
run
-
terminate
public void terminate()Terminate the Channel Factory
-