|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.BobCo.datalinks.TCPIPDataLink
Sample Director TCP/IP-base TWGDataLink
implementation.
This class implements a sample TCP/IP based communication driver for
supporting communications between the Director Console and Server.
The sample provides all the required methods, defined in the
TWGDataLink
interface, to support server-based and console-based
use of this class for unencrypted TCP/IP-based communications.
The class implementation supports an optional initialization string, which currently only supports an override value for the IP port number used by the server-based implmentation. If provided, the string can consist of a number representing the decimal value for the server's port address (default is 2034).
Any modification of this sample should use a different port address default.
TWGDataLink
Field Summary | |
---|---|
protected static int |
default_portnum
Default port number for server socket (set to 2034) |
protected boolean |
is_inited
|
protected boolean |
is_server_sock
|
protected int |
portnum
|
protected java.net.ServerSocket |
server_sock
|
protected java.net.Socket |
sock
|
Constructor Summary | |
---|---|
|
TCPIPDataLink()
Default constructor for TCPIPDataLink. |
protected |
TCPIPDataLink(java.net.Socket s)
Internal constructor used by server TCPIPDataLink to build
instances when sessions are accepted. |
Method Summary | |
---|---|
void |
TWGCloseLink()
Close connection to server or console. |
java.lang.String |
TWGGetHostname()
Return string representing host associated with link |
java.lang.String |
TWGGetLinkDriverName(java.util.Locale loc)
Return string representing name of data link driver |
void |
TWGInitializeConsoleLink(java.lang.String init_str)
Initialize a console TCPIPDataLink instance. |
void |
TWGInitializeServerLink(java.lang.String init_str)
Initialize a server TCPIPDataLink instance. |
boolean |
TWGOpenLink(java.lang.String hostname,
long authcode)
Open connection to server, using given host/target name. |
boolean |
TWGOpenLink(java.lang.String hostname,
java.lang.String userid,
java.lang.String password)
Open connection to server, using given host/target name. |
int |
TWGReadData(byte[] b,
int off,
int len)
Read data from opened connection. |
com.tivoli.twg.libs.TWGDataLink |
TWGServerListen()
Listen for link from console to a server TCPIPDataLink . |
void |
TWGWriteData(byte[] b,
int off,
int len)
Write data to opened connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final int default_portnum
protected java.net.Socket sock
protected java.net.ServerSocket server_sock
protected boolean is_server_sock
protected int portnum
protected boolean is_inited
Constructor Detail |
public TCPIPDataLink()
protected TCPIPDataLink(java.net.Socket s)
TCPIPDataLink
to build
instances when sessions are accepted.
s
- - socket to use for sessionMethod Detail |
public void TWGInitializeConsoleLink(java.lang.String init_str) throws java.io.IOException, com.tivoli.twg.libs.TWGInitParmException, com.tivoli.twg.libs.TWGLinkNotSupportedException
TCPIPDataLink
instance. Passes in a
parameter string which can either be null or include a decimal number providing
an override to the default port number (or * for no override).
Called after constructor and before TWGOpenLink()
is called.
TWGInitializeConsoleLink
in interface com.tivoli.twg.libs.TWGDataLink
init_str
- - initialization string from link configuration
IOException
- if communications error
TWGInitParmException
- if bad initialization string
TWGLinkNotSupportedException
- if link type not supported
java.io.IOException
com.tivoli.twg.libs.TWGInitParmException
com.tivoli.twg.libs.TWGLinkNotSupportedException
public boolean TWGOpenLink(java.lang.String hostname, java.lang.String userid, java.lang.String password) throws java.net.UnknownHostException, java.io.IOException
TWGOpenLink
in interface com.tivoli.twg.libs.TWGDataLink
hostname
- - string for identifying target serveruserid
- - string for userid to attempt for logonpassword
- - string for password for logon
UnknownHostException
- if bad hostname
IOException
- if communications error
java.net.UnknownHostException
java.io.IOException
public boolean TWGOpenLink(java.lang.String hostname, long authcode) throws java.net.UnknownHostException, java.io.IOException
TWGOpenLink
in interface com.tivoli.twg.libs.TWGDataLink
hostname
- - string for identifying target serverauthcode
- - long for authentication code
UnknownHostException
- if bad hostname
IOException
- if communications error
java.net.UnknownHostException
java.io.IOException
public void TWGWriteData(byte[] b, int off, int len) throws java.io.IOException
TWGReadData
call on the receiving end of
the link.
TWGWriteData
in interface com.tivoli.twg.libs.TWGDataLink
b
- - source bufferoff
- - index of first byte to write from bufferlen
- - number of bytes to write from buffer
IOException
- - if error during write operation
java.io.IOException
public int TWGReadData(byte[] b, int off, int len) throws java.io.IOException
TWGReadData
in interface com.tivoli.twg.libs.TWGDataLink
b
- - destination bufferoff
- - index of first byte to read into bufferlen
- - number of bytes to read into buffer
IOException
- - if error during read operation
java.io.IOException
public void TWGCloseLink() throws java.io.IOException
TWGCloseLink
in interface com.tivoli.twg.libs.TWGDataLink
java.io.IOException
public void TWGInitializeServerLink(java.lang.String init_str) throws java.io.IOException, com.tivoli.twg.libs.TWGInitParmException, com.tivoli.twg.libs.TWGLinkNotSupportedException
TCPIPDataLink
instance. Passes in a parameter
string which can either be null or include a decimal number providing
an override to the default port number (or * for no override).
TWGInitializeServerLink
in interface com.tivoli.twg.libs.TWGDataLink
init_str
- - initialization string from link configuration
IOException
- if communications error
TWGInitParmException
- if bad initialization string
TWGLinkNotSupportedException
- if link type not supported
java.io.IOException
com.tivoli.twg.libs.TWGInitParmException
com.tivoli.twg.libs.TWGLinkNotSupportedException
public com.tivoli.twg.libs.TWGDataLink TWGServerListen() throws java.io.IOException
TCPIPDataLink
.
Blocks until a connection occurs, which results in the return of a
TCPIPDataLink
instance representing the server-to-console
connection, or until an error occurs.
TWGServerListen
in interface com.tivoli.twg.libs.TWGDataLink
TCPIPDataLink
instance for the opened session
IOException
- on an error or when the server
TCPIPDataLink
is closed using TWGCloseLink()
.
java.io.IOException
public java.lang.String TWGGetHostname()
TWGGetHostname
in interface com.tivoli.twg.libs.TWGDataLink
public java.lang.String TWGGetLinkDriverName(java.util.Locale loc)
TWGGetLinkDriverName
in interface com.tivoli.twg.libs.TWGDataLink
loc
- - locale to be used to return name
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |