com.adventnet.management.transport
Class TcpSessionTransportImpl
java.lang.Object
|
+--com.adventnet.management.transport.TcpSessionTransportImpl
- public class TcpSessionTransportImpl
- extends java.lang.Object
- implements SessionTransportProvider
Implementation of the SessionTransportProvider interface that provides the
session communiation with TCP/IP as the lower layer transport. This class
implements all the IO operations (open, close, read, write) required by the
session communication.
|
Field Summary |
(package private) java.io.DataInputStream |
in
|
(package private) java.io.DataOutputStream |
out
|
(package private) java.net.Socket |
socket
|
|
Constructor Summary |
TcpSessionTransportImpl(java.net.Socket sock)
Constructor for this class that takes a TCP Socket instance as an argument. |
|
Method Summary |
int |
close()
Closes the transport interface after communication is over. |
java.net.InetAddress |
getAddress()
Returns the socket address of the TCP socket. |
java.lang.String |
getHostName()
Returns the hostname of the TCP socket. |
int |
getPort()
Returns the port of the TCP socket. |
int |
open(java.lang.String[] params)
Opens the session over which the data is sent/received
Note: Presently this is not intended to be called by the API user since
the TcpClientTransportImpl internally creates the session object. |
byte[] |
read()
Receive data from the peer over the transport interface. |
int |
write(byte[] buf,
int len)
Send data to the server over the TCP server socket interface. |
| Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
socket
java.net.Socket socket
out
java.io.DataOutputStream out
in
java.io.DataInputStream in
TcpSessionTransportImpl
public TcpSessionTransportImpl(java.net.Socket sock)
- Constructor for this class that takes a TCP Socket instance as an argument.
open
public int open(java.lang.String[] params)
throws TransportException
- Opens the session over which the data is sent/received
Note: Presently this is not intended to be called by the API user since
the TcpClientTransportImpl internally creates the session object.
- Specified by:
- open in interface SessionTransportProvider
- Parameters:
params - parameters required for opening the session interface.- Returns:
- OK on success or ERROR in case of error.
- Throws:
- TransportException - in case of an error during opening the
transport interface.
write
public int write(byte[] buf,
int len)
throws TransportException
- Send data to the server over the TCP server socket interface.
- Specified by:
- write in interface SessionTransportProvider
- Parameters:
buf - Buffer that contains the bytes to be sent.len - number of bytes to send- Returns:
- OK on succesful write or ERROR on error
- Throws:
- TransportException - in case of an error during send.
read
public byte[] read()
throws TransportException
- Receive data from the peer over the transport interface.
- Specified by:
- read in interface SessionTransportProvider
- Returns:
- byte array in which the bytes are read into.
- Throws:
- TransportException - in case of an error during receive.
close
public int close()
throws TransportException
- Closes the transport interface after communication is over.
- Specified by:
- close in interface SessionTransportProvider
- Returns:
- OK in case of a successful close or returns ERROR on error.
- Throws:
- TransportException - in case of an error during closing.
getPort
public int getPort()
- Returns the port of the TCP socket.
- Returns:
- the port number used by this socket interface.
getAddress
public java.net.InetAddress getAddress()
- Returns the socket address of the TCP socket.
- Returns:
- the address used by this socket interface.
getHostName
public java.lang.String getHostName()
- Returns the hostname of the TCP socket.
- Returns:
- the hostname associated with this Socket interface.