|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
public interface SocketWrapper
This interface is common to all classes wrapping an underlying socket connections.
The underlying socket API can be either based on a socket channel (blocking or non-blocking),
or just based on a plain socket.
| Field Summary | |
|---|---|
static int |
SOCKET_RECEIVE_BUFFER_SIZE
Size of receive buffer size for socket connections. |
| Method Summary | |
|---|---|
void |
close()
Close the underlying socket connection. |
void |
flush()
Flush the data currently in the send buffer. |
String |
getHost()
Get the remote host the underlying socket connects to. |
int |
getPort()
Get the remote port the underlying socket connects to. |
ObjectSerializer |
getSerializer()
Get an object serializer / deserializer to convert an object to or from an array of bytes. |
Socket |
getSocket()
Get the underlying socket used by this socket wrapper. |
long |
getSocketTimestamp()
Returns a timestamp that should reflect the system millisecond counter at the last known good usage of the underlying socket. |
boolean |
isOpened()
Determine whether this socket client is opened or not. |
void |
open()
Open the underlying socket connection. |
int |
read(byte[] data,
int offset,
int len)
Read len bytes from a TCP connection into a byte array, starting
at position offset in that array. |
int |
readInt()
Read an int value from a socket connection. |
Object |
receive()
Read an object from a TCP socket connection. |
Object |
receive(int timeout)
Read an object from a TCP socket connection. |
JPPFBuffer |
receiveBytes(int timeout)
Read an array of bytes from a TCP socket connection. |
void |
send(Object o)
Send an object over a TCP socket connection. |
void |
sendBytes(JPPFBuffer buf)
Send an array of bytes over a TCP socket connection. |
void |
setHost(String host)
Set the remote host the underlying socket connects to. |
void |
setPort(int port)
Get the remote port the underlying socket connects to. |
void |
setSerializer(ObjectSerializer serializer)
Set the object serializer / deserializer to convert an object to or from an array of bytes. |
void |
setSocket(Socket socket)
Set the underlying socket to be used by this socket wrapper. |
int |
skip(int n)
Skip n bytes of data from the socket or channel input stream. |
void |
write(byte[] data,
int offset,
int len)
Send an array of bytes over a TCP socket connection. |
void |
writeInt(int n)
Write an int value over a socket connection. |
| Field Detail |
|---|
static final int SOCKET_RECEIVE_BUFFER_SIZE
| Method Detail |
|---|
void send(Object o)
throws Exception
o - the object to send.
Exception - if the underlying output stream throws an exception.
void sendBytes(JPPFBuffer buf)
throws Exception
buf - the buffer container for the data to send.
Exception - if the underlying output stream throws an exception.
void write(byte[] data,
int offset,
int len)
throws Exception
data - the data to send.offset - the position where to start reading data from the input array.len - the length of data to write.
Exception - if the underlying output stream throws an exception.
void writeInt(int n)
throws Exception
n - the value to write.
Exception - if the underlying output stream throws an exception.
void flush()
throws IOException
IOException - if an I/O error occurs.
Object receive()
throws Exception
Exception - if the underlying input stream throws an exception.
Object receive(int timeout)
throws Exception
timeout - timeout after which the operation is aborted. A timeout of zero is interpreted as an infinite timeout.
Exception - if the underlying input stream throws an exception.
int read(byte[] data,
int offset,
int len)
throws Exception
len bytes from a TCP connection into a byte array, starting
at position offset in that array.
This method blocks until at least one byte of data is received.
data - an array of bytes into which the data is stored.offset - the position where to start storing data read from the socket.len - the length of data to read.
Exception - if the underlying input stream throws an exception.
int readInt()
throws Exception
Exception - if the underlying input stream throws an exception.
JPPFBuffer receiveBytes(int timeout)
throws Exception
timeout - timeout after which the operation is aborted. A timeout of zero is interpreted as an infinite timeout.
Exception - if the underlying input stream throws an exception.
int skip(int n)
throws Exception
n bytes of data from the socket or channel input stream.
n - the number of bytes to skip.
Exception - if an IO error occurs.
void open()
throws Exception
Exception - if the underlying input and output streams raise an error.
void close()
throws Exception
Exception - if the underlying input and output streams raise an error.boolean isOpened()
ObjectSerializer getSerializer()
ObjectSerializer instance.void setSerializer(ObjectSerializer serializer)
serializer - an ObjectSerializer instance.String getHost()
void setHost(String host)
host - the host name or ip address as a string.int getPort()
void setPort(int port)
port - the port number on the remote host.Socket getSocket()
void setSocket(Socket socket)
socket - a Socket instance.long getSocketTimestamp()
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||