public class ChannelFactory extends java.lang.Thread
SocketChannel| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PORT
default port of socket.
|
| Constructor and Description |
|---|
ChannelFactory()
Constructs a ChannelFactory on the DEFAULT_PORT.
|
ChannelFactory(int p)
Constructs a ChannelFactory.
|
| Modifier and Type | Method and Description |
|---|---|
SocketChannel |
getChannel()
Get a new socket channel from a server socket.
|
SocketChannel |
getChannel(java.lang.String h)
Get a new socket channel to a given host.
|
SocketChannel |
getChannel(java.lang.String h,
int p)
Get a new socket channel to a given host.
|
void |
init()
thread initialization and start.
|
void |
run()
Run the servers accept() in an infinite loop.
|
void |
terminate()
Terminate the Channel Factory
|
java.lang.String |
toString()
toString.
|
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, yieldpublic static final int DEFAULT_PORT
public ChannelFactory()
public ChannelFactory(int p)
p - port.public java.lang.String toString()
toString in class java.lang.Threadpublic void init()
public SocketChannel getChannel() throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic SocketChannel getChannel(java.lang.String h) throws java.io.IOException
h - hostnamejava.io.IOExceptionpublic SocketChannel getChannel(java.lang.String h, int p) throws java.io.IOException
h - hostnamep - portjava.io.IOExceptionpublic void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void terminate()