|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

public interface IBlockingConnection
A connection which uses the underlying channel in a blocking manner. Every I/O operation
will block until it completes.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.xsocket.stream.IConnection |
|---|
IConnection.FlushMode |
| Field Summary | |
|---|---|
static long |
INITIAL_RECEIVE_TIMEOUT
|
| Fields inherited from interface org.xsocket.stream.IConnection |
|---|
INITIAL_AUTOFLUSH, INITIAL_DEFAULT_ENCODING, SO_KEEPALIVE, SO_LINGER, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, TCP_NODELAY |
| Method Summary | |
|---|---|
void |
flush()
flush the send buffer. |
int |
getIndexOf(java.lang.String str)
Returns the index of the first occurrence of the given string. |
int |
getIndexOf(java.lang.String str,
int maxLength)
Returns the index of the first occurrence of the given string. |
byte |
readByte()
receive a byte. the method will block, until data is available |
java.nio.ByteBuffer[] |
readByteBufferByDelimiter(java.lang.String delimiter)
receive a ByteBuffer. the method will block, until the delimiter has been read. |
java.nio.ByteBuffer[] |
readByteBufferByDelimiter(java.lang.String delimiter,
int maxLength)
receive a ByteBuffer. the method will block, until the delimiter has been read. |
java.nio.ByteBuffer[] |
readByteBufferByLength(int length)
receive a ByteBuffer. the method will block, until the required amount of bytes has been received For performance reasons, the ByteBuffer receiveByteBuffer method is generally preferable to get bytes |
byte[] |
readBytesByDelimiter(java.lang.String delimiter)
receive a byte array. the method will block, until the delimiter has been read. |
byte[] |
readBytesByDelimiter(java.lang.String delimiter,
int maxLength)
receive a byte array. the method will block, until the delimiter has been read. |
byte[] |
readBytesByLength(int length)
receive a byte array. the method will block, until the required amount of bytes has been received For performance reasons, the ByteBuffer receiveByteBuffer method is generally preferable to get bytes |
double |
readDouble()
receive a double. the method will block, until data is available |
int |
readInt()
receive an int. the method will block, until data is available |
long |
readLong()
receive a long. the method will block, until data is available |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter)
receive a string. the method will block, until the delimiter has been read. |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
int maxLength)
receive a string. the method will block, until the delimiter has been read. |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding)
receive a string. the method will block, until the delimiter has been read To avoid memory leaks the readStringByDelimiter(String, String) method is generally preferable |
java.lang.String |
readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding,
int maxLength)
receive a string. the method will block, until the delimiter has been read |
java.lang.String |
readStringByLength(int length)
receive a string. |
java.lang.String |
readStringByLength(int length,
java.lang.String encoding)
receive a string. |
IBlockingConnection |
setOption(java.lang.String name,
java.lang.Object value)
sets the value of a option |
void |
setReceiveTimeoutMillis(long timeout)
set the timeout for calling read methods in millis |
int |
write(byte... bytes)
sends bytes to the remote endpoint |
int |
write(byte b)
sends a byte to the remote endpoint |
int |
write(byte[] bytes,
int offset,
int length)
sends bytes to the remote endpoint |
int |
write(java.nio.ByteBuffer buffer)
sends a byte buffer to the remote endpoint |
long |
write(java.nio.ByteBuffer[] buffers)
sends an array of byte buffer to the remote endpoint |
int |
write(double d)
sends a double to the remote endpoint |
int |
write(int i)
sends an int to the remote endpoint |
int |
write(long l)
sends a long to the remote endpoint |
int |
write(java.lang.String message)
sends a message to the remote endpoint by using the connection default encoding |
int |
write(java.lang.String message,
java.lang.String encoding)
sends a message to the remote endpoint |
| Methods inherited from interface org.xsocket.IDataSource |
|---|
readShort |
| Methods inherited from interface org.xsocket.IDataSink |
|---|
write |
| Methods inherited from interface java.nio.channels.GatheringByteChannel |
|---|
write |
| Methods inherited from interface java.nio.channels.Channel |
|---|
close |
| Methods inherited from interface java.nio.channels.ReadableByteChannel |
|---|
read |
| Field Detail |
|---|
static final long INITIAL_RECEIVE_TIMEOUT
| Method Detail |
|---|
void setReceiveTimeoutMillis(long timeout)
timeout - the timeout in millis
java.lang.String readStringByDelimiter(java.lang.String delimiter)
throws java.io.IOException,
ClosedConnectionException,
java.io.UnsupportedEncodingException,
java.net.SocketTimeoutException
readStringByDelimiter(String, int) method is generally preferable
readStringByDelimiter in interface IConnectionreadStringByDelimiter in interface IDataSourcedelimiter - the delimiter
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached
java.io.UnsupportedEncodingException - if the default encoding is not supported
java.lang.String readStringByDelimiter(java.lang.String delimiter,
int maxLength)
throws java.io.IOException,
ClosedConnectionException,
java.io.UnsupportedEncodingException,
java.net.SocketTimeoutException,
MaxReadSizeExceededException
readStringByDelimiter in interface IConnectionreadStringByDelimiter in interface IDataSourcedelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached
java.io.UnsupportedEncodingException - if the default encoding is not supported
java.lang.String readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding)
throws java.io.IOException,
ClosedConnectionException,
java.io.UnsupportedEncodingException,
java.net.SocketTimeoutException
readStringByDelimiter(String, String) method is generally preferable
readStringByDelimiter in interface IConnectiondelimiter - the delimiterencoding - the encoding to use
java.net.SocketTimeoutException - If the receive timeout has been reached
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - If the given encoding is not supported
ClosedConnectionException - If the underlying socket is already closed
java.lang.String readStringByDelimiter(java.lang.String delimiter,
java.lang.String encoding,
int maxLength)
throws java.io.IOException,
ClosedConnectionException,
java.io.UnsupportedEncodingException,
java.net.SocketTimeoutException,
MaxReadSizeExceededException
readStringByDelimiter in interface IConnectionreadStringByDelimiter in interface IDataSourcedelimiter - the delimiterencoding - the encoding to usemaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found * @throws ClosedConnectionException If the underlying socket is already closed
java.net.SocketTimeoutException - If the receive timeout has been reached
java.io.IOException - If some other I/O error occurs
java.io.UnsupportedEncodingException - If the given encoding is not supported
ClosedConnectionException - If the underlying socket is already closed
java.lang.String readStringByLength(int length)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readStringByLength in interface IConnectionreadStringByLength in interface IDataSourcelength - the number of bytes to read
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.lang.String readStringByLength(int length,
java.lang.String encoding)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readStringByLength in interface IConnectionreadStringByLength in interface IDataSourcelength - the number of bytes to readencoding - the encoding
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readByteBufferByDelimiter(String, int) method is generally preferable
readByteBufferByDelimiter in interface IConnectiondelimiter - the delimiter
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter,
int maxLength)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException,
MaxReadSizeExceededException
readByteBufferByDelimiter in interface IConnectiondelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.nio.ByteBuffer[] readByteBufferByLength(int length)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readByteBufferByLength in interface IConnectionlength - the number of bytes to read
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
byte[] readBytesByDelimiter(java.lang.String delimiter)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readBytesByDelimiter(String, int) method is generally preferable
readBytesByDelimiter in interface IConnectiondelimiter - the delimiter
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
byte[] readBytesByDelimiter(java.lang.String delimiter,
int maxLength)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException,
MaxReadSizeExceededException
readBytesByDelimiter in interface IConnectionreadBytesByDelimiter in interface IDataSourcedelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
int getIndexOf(java.lang.String str)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
getIndexOf in interface IConnectionstr - any string
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached
int getIndexOf(java.lang.String str,
int maxLength)
throws java.io.IOException,
ClosedConnectionException,
MaxReadSizeExceededException,
java.net.SocketTimeoutException
getIndexOf in interface IConnectionstr - any stringmaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
java.net.SocketTimeoutException - If the receive timeout has been reached
byte[] readBytesByLength(int length)
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readBytesByLength in interface IConnectionreadBytesByLength in interface IDataSourcelength - the number of bytes to read
java.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
int readInt()
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readInt in interface IConnectionreadInt in interface IDataSourcejava.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
long readLong()
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readLong in interface IConnectionreadLong in interface IDataSourcejava.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
double readDouble()
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readDouble in interface IConnectionreadDouble in interface IDataSourcejava.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
byte readByte()
throws java.io.IOException,
ClosedConnectionException,
java.net.SocketTimeoutException
readByte in interface IConnectionreadByte in interface IDataSourcejava.net.SocketTimeoutException - If the receive timeout has been reached
ClosedConnectionException - If the underlying socket is already closed
java.io.IOException - If some other I/O error occurs
int write(java.lang.String message,
java.lang.String encoding)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkmessage - the message to sendencoding - the encoding which should be used th encode the chars into byte (e.g. `US-ASCII` or `UTF-8`)
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(java.lang.String message)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkmessage - the message to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(byte b)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkb - the byte to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(byte... bytes)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkbytes - the bytes to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(byte[] bytes,
int offset,
int length)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkbytes - the bytes to sendoffset - The offset of the subarray to be used; must be non-negative and no larger than array.length. The new buffer`s position will be set to this value.length - The length of the subarray to be used; must be non-negative and no larger than array.length - offset. The new buffer`s limit will be set to offset + length.
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(java.nio.ByteBuffer buffer)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkwrite in interface java.nio.channels.WritableByteChannelbuffer - the bytes to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
long write(java.nio.ByteBuffer[] buffers)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface java.nio.channels.GatheringByteChannelwrite in interface IConnectionwrite in interface IDataSinkbuffers - the bytes to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(int i)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinki - the int value to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(long l)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkl - the int value to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
int write(double d)
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
write in interface IConnectionwrite in interface IDataSinkd - the int value to send
java.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the receive timeout has been reached (will only been thrown if autoflush = true)
ClosedConnectionException - if the underlying channel is closed
void flush()
throws ClosedConnectionException,
java.io.IOException,
java.net.SocketTimeoutException
flush in interface java.io.Flushableflush in interface IConnectionjava.io.IOException - If some other I/O error occurs
java.net.SocketTimeoutException - If the timeout has been reached
ClosedConnectionException - if the underlying channel is closed
IBlockingConnection setOption(java.lang.String name,
java.lang.Object value)
throws java.io.IOException
setOption in interface IConnectionname - the name of the optionvalue - the value of the option
java.io.IOException - In an I/O error occurs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||