|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
org.opengts.util.ServerSocketThread
public class ServerSocketThread
| Nested Class Summary | |
|---|---|
class |
ServerSocketThread.ServerSessionThread
ServerSessionThread |
static interface |
ServerSocketThread.SessionInfo
SessionInfo |
static class |
ServerSocketThread.SSEndOfStreamException
SSEndOfStreamException |
static class |
ServerSocketThread.SSReadTimeoutException
SSReadTimeoutException |
static class |
ServerSocketThread.SSSessionTimeoutException
SSSessionTimeoutException |
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
static boolean |
ACK_FROM_LISTEN_PORT
|
static int |
PACKET_LEN_END_OF_STREAM
|
static int |
PACKET_LEN_INCREMENT_EOL
|
static int |
PACKET_LEN_INCREMENTAL_
|
static int |
PACKET_LEN_INCREMENTAL_MASK
|
static int |
PACKET_LEN_LINE_TERMINATOR
|
static int |
PACKET_LEN_MATCH_PATTERN
|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
ServerSocketThread(java.net.DatagramSocket ds)
Constructor for UDP connections |
|
ServerSocketThread(java.net.InetAddress bindAddr,
int port)
Constructor for TCP connections |
|
ServerSocketThread(java.net.InetAddress bindAddr,
int port,
boolean useSSL)
Constructor for TCP connections |
|
ServerSocketThread(int port)
Constructor for TCP connections |
|
ServerSocketThread(int port,
boolean useSSL)
Constructor for TCP connections |
|
ServerSocketThread(java.net.ServerSocket ss)
Constructor for TCP connections |
|
| Method Summary | |
|---|---|
void |
addActionListener(java.awt.event.ActionListener al)
Adds an action listener |
static java.net.DatagramSocket |
createDatagramSocket(java.net.InetAddress bindAddr,
int port)
Creates a DatagramSocket bound to the default local interface |
static java.net.DatagramSocket |
createDatagramSocket(int port)
Creates a DatagramSocket bound to the default local interface |
static java.net.ServerSocket |
createServerSocket(java.net.InetAddress bindAddr,
int port)
Creates a ServerSocket bound to the default local interface |
int[] |
getBackspaceChar()
Gets the backspace characters |
java.net.InetAddress |
getBindAddress()
Gets the local bind address |
ClientPacketHandler |
getClientPacketHandler()
Gets the current client packet handler |
java.net.DatagramSocket |
getDatagramSocket()
Gets the bound UDP DatagramSocket for this server handler. |
static java.net.InetAddress |
getDefaultBindAddress()
Gets the local bind address for all created ServerSocket's, or null if no specific bind address has been set |
long |
getIdleTimeout()
Gets the idle timeout in milliseconds |
int[] |
getIgnoreChar()
Gets the characters to ignore |
boolean |
getIncludePacketLineTerminator()
Returns True if the line terminator character should be included in the returned packet |
int[] |
getLineTerminatorChar()
Gets the line terminator characters |
int |
getLingerTimeoutSec()
Gets the linger timeout in seconds |
int |
getLocalPort()
Gets the local port to which this socket is bound |
int |
getMaximumPacketLength()
Gets the maximum packet length |
int |
getMinimumPacketLength()
Gets the minimum packet length |
static java.net.InetAddress[] |
getNetworkInterfaceAddresses()
Returns an array of all local network interface addresses (excluding loopback) |
byte[] |
getPacketTerminatorPattern()
Returns the packet terminator pattern |
long |
getPacketTimeout()
Gets the packet timeout in milliseconds |
protected byte[] |
getPrompt(int ndx)
Gets the prompt for a specified index |
protected int |
getPromptIndex()
Gets the current prompt index (used for auto prompt) |
int |
getRemotePort()
Gets the remote UDP response port |
java.net.ServerSocket |
getServerSocket()
Gets the bound TCP ServerSocket for this server handler. |
long |
getSessionTimeout()
Gets the session timeout in milliseconds |
boolean |
getTerminateOnTimeout()
Gets if the thread should be terminated after a timeout [CHECK] |
static boolean |
hasBindAddress()
Returns true if a local bind address has been defined, otherwise false |
boolean |
hasListeners()
Returns true if this object has action listeners |
boolean |
hasPrompt()
If this server has a valid prompt |
boolean |
includePacketLineTerminator()
Returns True if the line terminator character should be included in the returned packet |
protected boolean |
invokeListeners(byte[] msgBytes)
Invokes action listener with the specified message |
boolean |
isBackspaceChar(int ch)
Returns true if ch is a backspace character |
boolean |
isIgnoreChar(int ch)
Returns true if ch is a character to ignore |
boolean |
isLineTerminatorChar(int ch)
Returns true if ch is a line terminator |
static boolean |
isLocalInterfaceAddress(java.net.InetAddress addr)
Returns true if the specified InetAddress is a local bound interface (including loopback) |
boolean |
isTextPackets()
Returns true if the packets are text |
static boolean |
isValidPort(int port)
Returns true if the specified port is valid |
void |
removeActionListener(java.awt.event.ActionListener al)
Removes an action listener |
void |
run()
Listens for incoming connections and dispatches them to a handler thread |
static void |
sendDatagram(java.net.InetAddress host,
int port,
byte[] data)
Sends a datagram to the specified host:port |
void |
setAutoPrompt(boolean auto)
If a default automatically generated prompt should be used [CHECK](all prompt related below) |
void |
setBackspaceChar(int bs)
Sets the backspace character |
void |
setBackspaceChar(int[] bs)
Sets the backspace characters |
static void |
setBindAddress(java.net.InetAddress bindAddr)
Sets the local bind address for all created ServerSocket's |
void |
setClientPacketHandler(ClientPacketHandler cph)
Sets the client packet handler [CHECK] |
void |
setClientPacketHandlerClass(java.lang.Class cphc)
Sets the client packet handler class [CHECK] |
void |
setIdleTimeout(long timeoutMS)
Sets the idle timeout in milliseconds |
void |
setIgnoreChar(int[] bs)
Sets the characters to ignore |
void |
setIncludePacketLineTerminator(boolean rtnTerm)
Sets whether the line terminator character should be included in the returned packets |
void |
setLineTerminatorChar(int term)
Sets the line terminator character |
void |
setLineTerminatorChar(int[] term)
Sets the line terminator characters |
void |
setLingerTimeoutSec(int timeoutSec)
Sets the linger timeout in seconds |
static void |
setListenBacklog(int backlog)
Sets the listen backlog for all created ServerSocket's |
void |
setMaximumPacketLength(int len)
Sets the maximum packet length |
void |
setMinimumPacketLength(int len)
Sets the minimum packet length |
void |
setPacketTerminatorPattern(byte[] pktTerm)
Sets the packet terminator pattern |
void |
setPacketTimeout(long timeoutMS)
Sets the packet timeout in milliseconds |
void |
setPrompt(byte[] prompt)
Sets the prompt for TCP connections |
void |
setPrompt(java.lang.String prompt)
Sets the prompt for TCP connections |
void |
setRemotePort(int remotePort)
Sets the remote UDP response port |
void |
setSessionTimeout(long timeoutMS)
Sets the session timeout in milliseconds |
void |
setTerminateOnTimeout(boolean timeoutQuit)
Sets if the thread should be terminated after a timeout [CHECK] |
void |
setTextPackets(boolean isText)
Sets if the packets to be sent are text |
void |
shutdown()
Shuts down the server |
boolean |
tcpWriteToSessionID(java.lang.String sessionID,
byte[] data)
Find the named TCP session and write the specified bytes TCP output stream |
void |
testSession(byte[] data)
Run a test session from the specified input data array |
void |
testSession(java.io.InputStream dataInput)
Run a test session from the specified input stream |
| Methods inherited from class java.lang.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, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int PACKET_LEN_INCREMENTAL_
public static final int PACKET_LEN_INCREMENTAL_MASK
public static final int PACKET_LEN_LINE_TERMINATOR
public static final int PACKET_LEN_END_OF_STREAM
public static final int PACKET_LEN_MATCH_PATTERN
public static final int PACKET_LEN_INCREMENT_EOL
public static final boolean ACK_FROM_LISTEN_PORT
| Constructor Detail |
|---|
public ServerSocketThread(java.net.DatagramSocket ds)
public ServerSocketThread(java.net.ServerSocket ss)
ss - The ServerSocket containing the 'listen' port information
public ServerSocketThread(java.net.InetAddress bindAddr,
int port)
throws java.io.IOException
port - The port on which to listen for incoming connections
java.io.IOException
public ServerSocketThread(int port)
throws java.io.IOException
port - The port on which to listen for incoming connections
java.io.IOException
public ServerSocketThread(java.net.InetAddress bindAddr,
int port,
boolean useSSL)
throws java.io.IOException
port - The port on which to listen for incoming connectionsuseSSL - True to enable an SSL
java.io.IOException
public ServerSocketThread(int port,
boolean useSSL)
throws java.io.IOException
port - The port on which to listen for incoming connectionsuseSSL - True to enable an SSL
java.io.IOException| Method Detail |
|---|
public static void setListenBacklog(int backlog)
backlog - The listen backlogpublic static void setBindAddress(java.net.InetAddress bindAddr)
bindAddr - The local bind addresspublic static boolean hasBindAddress()
public static java.net.InetAddress getDefaultBindAddress()
public static java.net.InetAddress[] getNetworkInterfaceAddresses()
throws java.net.SocketException
java.net.SocketExceptionpublic static boolean isLocalInterfaceAddress(java.net.InetAddress addr)
public static java.net.DatagramSocket createDatagramSocket(java.net.InetAddress bindAddr,
int port)
throws java.net.SocketException
java.net.SocketException
public static java.net.DatagramSocket createDatagramSocket(int port)
throws java.net.SocketException
java.net.SocketException
public static java.net.ServerSocket createServerSocket(java.net.InetAddress bindAddr,
int port)
throws java.io.IOException
java.io.IOExceptionpublic static boolean isValidPort(int port)
port - The port to test
public java.net.DatagramSocket getDatagramSocket()
public java.net.ServerSocket getServerSocket()
public int getLocalPort()
public java.net.InetAddress getBindAddress()
public void testSession(byte[] data)
data - The test input data arraypublic void testSession(java.io.InputStream dataInput)
dataInput - The test input streampublic void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void shutdown()
public void setRemotePort(int remotePort)
remotePort - The remote UDP respose portpublic int getRemotePort()
public boolean hasListeners()
public void addActionListener(java.awt.event.ActionListener al)
al - The action listener to addpublic void removeActionListener(java.awt.event.ActionListener al)
al - The action listener to remove
protected boolean invokeListeners(byte[] msgBytes)
throws java.lang.Exception
msgBytes - The message to invoke the listeners with as a byte array
java.lang.Exceptionpublic void setClientPacketHandler(ClientPacketHandler cph)
cph - The client packet handlerpublic void setClientPacketHandlerClass(java.lang.Class cphc)
cphc - The client packet handler classpublic ClientPacketHandler getClientPacketHandler()
public void setSessionTimeout(long timeoutMS)
timeoutMS - The session timeout in millisecondspublic long getSessionTimeout()
public void setIdleTimeout(long timeoutMS)
timeoutMS - The idle timeout in millisecondspublic long getIdleTimeout()
public void setPacketTimeout(long timeoutMS)
timeoutMS - The packet timeout in millisecondspublic long getPacketTimeout()
public void setTerminateOnTimeout(boolean timeoutQuit)
timeoutQuit - True if the thread should be terminated after a timeoutpublic boolean getTerminateOnTimeout()
public void setLingerTimeoutSec(int timeoutSec)
timeoutSec - The linger timeout in secondspublic int getLingerTimeoutSec()
public void setTextPackets(boolean isText)
isText - True if the packets are textpublic boolean isTextPackets()
public void setMaximumPacketLength(int len)
len - The maximum packet lengthpublic int getMaximumPacketLength()
public void setMinimumPacketLength(int len)
len - The minimum packet lengthpublic int getMinimumPacketLength()
public void setLineTerminatorChar(int term)
term - The line terminator characterpublic void setLineTerminatorChar(int[] term)
term - The line terminator characterspublic int[] getLineTerminatorChar()
public boolean isLineTerminatorChar(int ch)
ch is a line terminator
ch is a line terminatorpublic void setIncludePacketLineTerminator(boolean rtnTerm)
rtnTerm - True to include the line terminator character in returned packetspublic boolean getIncludePacketLineTerminator()
public boolean includePacketLineTerminator()
public void setPacketTerminatorPattern(byte[] pktTerm)
pktTerm - The packet terminator patternpublic byte[] getPacketTerminatorPattern()
public void setBackspaceChar(int bs)
bs - The backspace characterpublic void setBackspaceChar(int[] bs)
bs - The backspace characterspublic int[] getBackspaceChar()
public boolean isBackspaceChar(int ch)
ch is a backspace character
ch is a backspace characterpublic void setIgnoreChar(int[] bs)
bs - The characters to ignorepublic int[] getIgnoreChar()
public boolean isIgnoreChar(int ch)
ch is a character to ignore
ch is a character to ignorepublic void setAutoPrompt(boolean auto)
auto - Ture if default automatic prompt should be usedpublic void setPrompt(byte[] prompt)
prompt - The promptpublic void setPrompt(java.lang.String prompt)
prompt - The promptprotected byte[] getPrompt(int ndx)
ndx - The index (used for auto prompt)public boolean hasPrompt()
protected int getPromptIndex()
public boolean tcpWriteToSessionID(java.lang.String sessionID,
byte[] data)
sessionID - The session IDdata - The bytes to write
public static void sendDatagram(java.net.InetAddress host,
int port,
byte[] data)
throws java.io.IOException
host - The destination hostport - The destination portdata - The data to send
java.io.IOException - if an IO error occurs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||