|
SSH Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jscape.inet.ipclient.IpClient
Implements basic functionality of a TCP/IP client connection.
Example usage:
try {
// create new IpClient instance with hostname, port and timeout arguments
IpClient client = new IpClient("10.0.0.1",53,5000);
// establish connection with server
client.connect();
// obtain OutputStream for sending data to server
OutputStream out = client.getOutputStream();
// obtain InputStream for reading data from server
InputStream in = client.getInputStream();
// disconnect from server
client.disconnect();
} catch(IpClientException ipe) {
ipe.printStackTrace();
}
| Constructor Summary | |
IpClient(java.lang.String hostname,
int port)
Creates a new IpClient instance. |
|
IpClient(java.lang.String hostname,
int port,
int timeout)
Creates a new IpClient instance. |
|
| Method Summary | |
void |
addIpClientListener(IpClientListener listener)
Adds IpClient event listener |
void |
connect()
Establishes connection with server. |
void |
disconnect()
Closes connection with server. |
java.io.InputStream |
getInputStream()
Gets InputStream from socket connection established with server. |
java.io.OutputStream |
getOutputStream()
Gets OutputStream from socket connection established with server. |
java.net.Socket |
getSocket()
Gets Socket established after invoking the IpClient#connect method. |
void |
removeIpClientListener(IpClientListener listener)
Removes an IpClient event listener |
void |
setInputStream(java.io.InputStream input)
Replaces InputStream from socket connection established with server. |
void |
setOutputStream(java.io.OutputStream output)
Sets OutputStream from socket connection established with server. |
void |
setSocket(java.net.Socket socket)
Sets socket replacing current socket with new socket |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public IpClient(java.lang.String hostname,
int port)
hostname - the server hostname or IP addressport - the server port
public IpClient(java.lang.String hostname,
int port,
int timeout)
hostname - the server hostname or IP addressport - the server porttimeout - the timeout for establishing a connection specified in ms (milliseconds)| Method Detail |
public void addIpClientListener(IpClientListener listener)
listener - an IpClientListenerpublic void removeIpClientListener(IpClientListener listener)
listener - an IpClientListener
public void connect()
throws IpClientException
IpClientException - if an I/O or network related error occurspublic java.io.InputStream getInputStream()
public void setInputStream(java.io.InputStream input)
public java.io.OutputStream getOutputStream()
public void setOutputStream(java.io.OutputStream output)
output - public java.net.Socket getSocket()
connect()
public void setSocket(java.net.Socket socket)
throws IpClientException
socket - the new socket
IpClientException
public void disconnect()
throws IpClientException
IpClientException - if an I/O or network related error occurs
|
SSH Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||