java.lang.Object
|
+--stec.iws.SocketHandler
public abstract SocketHandler
Defines methods used by Servertec Internet Server to access open a
ServerSocket and Socket.
Methods
Method
|
Description
|
destroy
|
Called by the server to destroy the SocketHandler.
|
getServerSocket
|
Returns a new ServerSocket.
|
getSocket
|
Returns a new Socket.
|
init
|
Called by the server to initialize the SocketHandler.
|
destroy
Called by the server to destroy the SocketHandler.
Syntax
public void destroy()
Parameters
Returns
Throws
Example
public void destroy()
{
super.destroy();
}
getServerSocket
Returns a new ServerSocket.
Syntax
public ServerSocket getServerSocket(int port,
int backlog,
String address)
throws Exception
Parameters
port
|
the port number the ServerSocket listens on.
|
backlog
|
the maximum number of pending request to queue.
|
address
|
the IP address or the host name to listen to.
|
Returns
ServerSocket
|
the new ServerSocket.
|
Throws
Exception
|
Thrown when any error occurs.
|
Example
public ServerSocket getServerSocket(int port,
int backlog,
String address)
throws Exception
{
if(address == null)
{
return new ServerSocket(port, backlog);
}
else
{
InetAddress iaddress = InetAddress.getByName(address);
return new ServerSocket(port, backlog, iaddress);
}
}
getSocket
Returns a new Socket.
Syntax
public Socket getSocket(String hostname, int port)
throws Exception
Parameters
hostname
|
the name or IP address of the server to open a socket to.
|
port
|
the port number to use.
|
Returns
Throws
Exception
|
Thrown when any error occurs.
|
Example
public Socket getSocket(String hostname, int port)
throws Exception
{
return new Socket(hostname, port);
}
init
Called by the server to initialize the SocketHandler.
Syntax
public void init(Hashtable parameters) throws Exception
Parameters
parameters
|
contains any initialization paramters
|
Returns
Throws
Exception
|
Thrown when any error occurs.
|
Example
private String[] cipher_suites;
public void init(Hahstable parameters) throws Exception
{
super.init(parameters);
Object obj = parameters.get("cipher_suites");
if(obj = null)
{
cipher_suites = null;
}
else
{
cipher_suites = (String[])obj;
}
}
|