|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttw.net.Server
public abstract class Server
Abstract multithreaded server
Field Summary | |
---|---|
static int |
DEFAULT_PORT
default port (23229) |
static int |
LOCAL
pseudo port value for servers directly linked to clients |
static int |
UNBOUND
value indicating the server socket hasn't been bound to a port yet |
Method Summary | |
---|---|
void |
allowClientIP(java.lang.String pattern)
Adds an IP address or address pattern for clients acceptable by this server. |
void |
allowClientIPs(java.lang.String[] pattern)
Adds one or more IP address patterns for clients acceptable by this server. |
void |
forbidClientIP(java.lang.String pattern)
Adds an IP address or address pattern for clients not acceptable by this server. |
void |
forbidClientIPs(java.lang.String[] pattern)
Adds one or more IP address patterns for clients not acceptable by this server. |
java.lang.String |
getHostAddress()
Returns the IP of the host |
java.lang.String |
getHostName()
Returns the name of the host |
int |
getPort()
Returns the port which this server listens at |
int |
getPriority()
Informs about the main server thread's priority |
boolean |
isDaemon()
Tells whether the main server thread has daemon quality |
static void |
main(java.lang.String[] args)
|
void |
pleaseStop()
Asks the server to stop working |
void |
setDaemon(boolean a)
Sets the main server thread's daemon quality |
void |
setPriority(int a)
Sets the main server thread's priority |
void |
setVerbose(boolean value)
Tells the server to print some accompanying messages to the console. |
void |
start()
Starts the Server. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT
public static final int LOCAL
public static final int UNBOUND
Method Detail |
---|
public void start()
Starts the Server. Provided it is not the special case of a server directly linked to a client, it will begin to listen for clients.
public void setDaemon(boolean a)
a
- make the thread a daemon?public boolean isDaemon()
public void setPriority(int a)
a
- the desired prioritypublic int getPriority()
public java.lang.String getHostName()
public java.lang.String getHostAddress()
public int getPort()
public void allowClientIP(java.lang.String pattern)
Adds an IP address or address pattern for clients acceptable by this server. To allow a whole range of IPs, one or more numbers can be replaced by the asterisk *, e.g. "123.45.*.6" allows clients with the IPs in range 123.45.0.6 through 123.45.255.6. Instead of using trailing wildcards, a pattern can be abbreviated, e.g. instead of "123.45.*.*" you can simply use "123.45". Note that it is possible both to allow and to forbid client IPs. The possible scenarios are evaluated like this: If both an allow and a forbid pattern match on a given IP, the more specific of the two takes effect. (A pattern is more specific, if its leftmost wildcard is more to the right than in another pattern.) If the allow and forbid patterns are equal, the forbid pattern takes precedence: the IP is forbidden. If only an allow pattern matches, the IP is allowed. If only a forbid pattern matches, the IP is forbidden. If no pattern matches, the outcome depends on the existence of allow and forbid patterns: If there exist forbid patterns (that don't match the IP), the IP is allowed. If there are no forbid patterns but allow patterns (that don't match the IP), the IP is forbidden. If there are no patterns of any kind, access is unrestricted: the IP is allowed.
pattern
- an IP address or a pattern of suchforbidClientIP(java.lang.String)
public void allowClientIPs(java.lang.String[] pattern)
pattern
- an Array of IP addresses or patterns of suchallowClientIP(java.lang.String)
public void forbidClientIP(java.lang.String pattern)
Adds an IP address or address pattern for clients not acceptable by this server. To forbid a whole range of IPs, one or more numbers can be replaced by the asterisk *, e.g. "123.45.*.6" allows clients with the IPs in range 123.45.0.6 through 123.45.255.6. Instead of using trailing wildcards, a pattern can be abbreviated, e.g. instead of "123.45.*.*" you can simply use "123.45". Note that it is possible both to allow and to forbid client IPs. The possible scenarios are evaluated like this: If both an allow and a forbid pattern match on a given IP, the more specific of the two takes effect. (A pattern is more specific, if its leftmost wildcard is more to the right than in another pattern.) If the allow and forbid patterns are equal, the forbid pattern takes precedence: the IP is forbidden. If only an allow pattern matches, the IP is allowed. If only a forbid pattern matches, the IP is forbidden. If no pattern matches, the outcome depends on the existence of allow and forbid patterns: If there exist forbid patterns (that don't match the IP), the IP is allowed. If there are no forbid patterns but allow patterns (that don't match the IP), the IP is forbidden. If there are no patterns of any kind, access is unrestricted: the IP is allowed.
pattern
- an IP address or a pattern of suchallowClientIP(java.lang.String)
public void forbidClientIPs(java.lang.String[] pattern)
pattern
- an Array of IP addresses or patterns of suchforbidClientIP(java.lang.String)
public void pleaseStop()
public void setVerbose(boolean value)
Tells the server to print some accompanying messages to the console. Default is off.
value
- verbose on or offpublic static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |