public abstract class NetworkSession extends Object
Base class for client network sessions.
Constructor and Description |
---|
NetworkSession(String protoName)
Class constructor
|
Modifier and Type | Method and Description |
---|---|
abstract void |
Close()
Close the network session
|
static int |
getDefaultTimeout()
Return the default socket timeout value
|
String |
getProtocolName()
Return the protocol name
|
int |
getTimeout()
Return the send/receive timeout, in milliseconds
|
abstract boolean |
hasData()
Check if the network session has data available
|
abstract boolean |
isConnected()
Determine if the session is connected to a remote host
|
abstract void |
Open(String toName,
String fromName,
String toAddr)
Open a connection to a remote host
|
abstract int |
Receive(byte[] buf)
Receive a data packet from the remote host.
|
abstract boolean |
Send(byte[] data,
int siz)
Send a data packet to the remote host.
|
static void |
setDefaultTimeout(int tmo)
Set the default socket timeout for new sessions
|
void |
setTimeout(int tmo)
Set the send/receive timeout, in milliseconds
|
public NetworkSession(String protoName)
protoName
- Stringpublic final String getProtocolName()
public abstract void Open(String toName, String fromName, String toAddr) throws IOException, UnknownHostException
toName
- Host name/address being calledfromName
- Local host name/addresstoAddr
- Optional address of the remote hostIOException
UnknownHostException
public abstract boolean isConnected()
public abstract boolean hasData() throws IOException
IOException
public final int getTimeout()
public abstract int Receive(byte[] buf) throws IOException
buf
- Byte buffer to receive the data into.IOException
- I/O error occurred.public abstract boolean Send(byte[] data, int siz) throws IOException
data
- Byte array containing the data to be sent.siz
- Length of the data to send.IOException
- I/O error occurred.public abstract void Close() throws IOException
IOException
- I/O error occurredpublic void setTimeout(int tmo)
tmo
- intpublic static final int getDefaultTimeout()
public static final void setDefaultTimeout(int tmo)
tmo
- intCopyright © 2005–2018 Alfresco Software. All rights reserved.