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

java.lang.Objectorg.xsocket.stream.BlockingConnection
public final class BlockingConnection
Implementation of the IBlockingConnection interface. 
 A newly created connection is in the open state. The methods of this class are not thread-safe.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from interface org.xsocket.stream.IConnection | 
|---|
IConnection.FlushMode | 
| Field Summary | 
|---|
| Fields inherited from interface org.xsocket.stream.IBlockingConnection | 
|---|
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 | 
| Constructor Summary | |
|---|---|
BlockingConnection(java.net.InetAddress address,
                   int port)
constructor  | 
|
BlockingConnection(java.net.InetAddress address,
                   int port,
                   java.util.Map<java.lang.String,java.lang.Object> options)
Deprecated.  | 
|
BlockingConnection(java.net.InetAddress address,
                   int port,
                   java.util.Map<java.lang.String,java.lang.Object> options,
                   javax.net.ssl.SSLContext sslContext,
                   boolean sslOn)
constructor  | 
|
BlockingConnection(java.net.InetAddress address,
                   int port,
                   javax.net.ssl.SSLContext sslContext,
                   boolean sslOn)
constructor  | 
|
BlockingConnection(java.net.InetAddress address,
                   int port,
                   StreamSocketConfiguration socketConf)
Deprecated.  | 
|
BlockingConnection(java.net.InetAddress address,
                   int port,
                   StreamSocketConfiguration socketConf,
                   javax.net.ssl.SSLContext sslContext,
                   boolean sslOn)
Deprecated.  | 
|
BlockingConnection(java.lang.String hostname,
                   int port)
constructor.  | 
|
BlockingConnection(java.lang.String hostname,
                   int port,
                   java.util.Map<java.lang.String,java.lang.Object> options)
constructor.  | 
|
BlockingConnection(java.lang.String hostname,
                   int port,
                   java.util.Map<java.lang.String,java.lang.Object> options,
                   javax.net.ssl.SSLContext sslContext,
                   boolean sslOn)
constructor  | 
|
BlockingConnection(java.lang.String hostname,
                   int port,
                   javax.net.ssl.SSLContext sslContext,
                   boolean sslOn)
constructor  | 
|
BlockingConnection(java.lang.String hostname,
                   int port,
                   StreamSocketConfiguration socketConfiguration)
Deprecated.  | 
|
BlockingConnection(java.lang.String hostname,
                   int port,
                   StreamSocketConfiguration socketConf,
                   javax.net.ssl.SSLContext sslContext,
                   boolean sslOn)
Deprecated.  | 
|
| Method Summary | |
|---|---|
 void | 
activateSecuredMode()
ad hoc activation of a secured mode (SSL).  | 
 java.lang.Object | 
attach(java.lang.Object obj)
 | 
 java.lang.Object | 
attachment()
 | 
 void | 
close()
 | 
 void | 
flush()
flush the send buffer.  | 
 java.lang.Object | 
getAttachment()
Retrieves the current attachment.  | 
 boolean | 
getAutoflush()
get autoflush  | 
 int | 
getConnectionTimeoutSec()
gets the connection timeout  | 
 java.lang.String | 
getDefaultEncoding()
gets the default encoding for this connection (used by string related methods like readString...)  | 
 IConnection.FlushMode | 
getFlushmode()
get the flushmode  | 
 java.lang.String | 
getId()
returns the id  | 
 int | 
getIdleTimeoutSec()
returns the idle timeout in sec.  | 
 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.  | 
 int | 
getIndexOf(java.lang.String str,
           java.lang.String encoding,
           int maxLength)
Returns the index of the first occurrence of the given string.  | 
 java.net.InetAddress | 
getLocalAddress()
returns the local address  | 
 int | 
getLocalPort()
returns the local port  | 
 java.lang.Object | 
getOption(java.lang.String name)
returns the value of a option  | 
 java.util.Map<java.lang.String,java.lang.Class> | 
getOptions()
Returns an unmodifiable map of the options supported by this endpoint.  | 
 int | 
getPendingWriteDataSize()
returns the size of the data which have already been written, but not yet transferred to the underlying socket.  | 
 java.net.InetAddress | 
getRemoteAddress()
returns the remote address  | 
 int | 
getRemotePort()
returns the port of the remote endpoint  | 
 int | 
indexOf(java.lang.String str)
Deprecated. uses getIndexOf instead  | 
 boolean | 
isOpen()
returns, if the connection is open.  | 
 void | 
markReadPosition()
Marks the present read position in the connection.  | 
 void | 
markWritePosition()
Marks the present write position in the connection.  | 
 void | 
onWriteException(java.io.IOException ioException)
 | 
 void | 
onWritten()
 | 
 int | 
read(java.nio.ByteBuffer buffer)
.  | 
 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[] | 
readByteBufferByDelimiter(java.lang.String delimiter,
                          java.lang.String encoding,
                          int maxLength)
read a ByteBuffer by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes  | 
 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[] | 
readBytesByDelimiter(java.lang.String delimiter,
                     java.lang.String encoding,
                     int maxLength)
read a byte array by using a delimiter For performance reasons, the ByteBuffer readByteBuffer method is generally preferable to get bytes  | 
 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  | 
 short | 
readShort()
read a short value  | 
 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 IBlockingConnection.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.  | 
 void | 
removeReadMark()
remove the mark the present read position in the connection.  | 
 void | 
removeWriteMark()
remove the mark the present write position in the connection.  | 
 boolean | 
resetToReadMark()
Resets to the marked read position.  | 
 boolean | 
resetToWriteMark()
Resets to the marked write position.  | 
 void | 
resumeRead()
resume reading data from the underlying subsystem  | 
 void | 
setAttachment(java.lang.Object obj)
Attaches the given object to this connection  | 
 void | 
setAutoflush(boolean autoflush)
set autoflush.  | 
 void | 
setConnectionTimeoutSec(int timeoutSec)
sets the max time for a connections.  | 
 void | 
setDefaultEncoding(java.lang.String defaultEncoding)
sets the default encoding for this connection (used by string related methods like readString...)  | 
 void | 
setFlushmode(IConnection.FlushMode flushMode)
set the flushmode  | 
 void | 
setIdleTimeoutSec(int timeoutInSec)
sets the idle timeout in sec  | 
 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  | 
 void | 
suspendRead()
suspend reading data from the underlying subsystem  | 
 java.lang.String | 
toString()
 | 
 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.  | 
 long | 
write(java.nio.ByteBuffer[] srcs,
      int offset,
      int length)
 | 
 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(short s)
writes a short to the data sink  | 
 int | 
write(java.lang.String s)
sends a message to the remote endpoint by using the connection default encoding  | 
 int | 
write(java.lang.String s,
      java.lang.String encoding)
sends a message to the remote endpoint  | 
| Methods inherited from class java.lang.Object | 
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface org.xsocket.stream.IBlockingConnection | 
|---|
flush, write, write, write, write, write, write, write, write, write, write | 
| Methods inherited from interface org.xsocket.stream.IConnection | 
|---|
activateSecuredMode, attach, attachment, getAttachment, getAutoflush, getConnectionTimeoutSec, getDefaultEncoding, getId, getIdleTimeoutSec, getLocalAddress, getLocalPort, getOption, getOptions, getPendingWriteDataSize, getRemoteAddress, getRemotePort, isOpen, markReadPosition, markWritePosition, removeReadMark, removeWriteMark, resetToReadMark, resetToWriteMark, resumeRead, setAttachment, setAutoflush, setConnectionTimeoutSec, setDefaultEncoding, setIdleTimeoutSec, suspendRead | 
| 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 | 
| Constructor Detail | 
|---|
public BlockingConnection(java.lang.String hostname,
                          int port)
                   throws java.io.IOException
hostname - the remote hostport - the port of the remote host to connect
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.lang.String hostname,
                          int port,
                          StreamSocketConfiguration socketConfiguration)
                   throws java.io.IOException
hostname - the remote hostport - the port of the remote host to connectsocketConfiguration - the socket configuration
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.lang.String hostname,
                          int port,
                          java.util.Map<java.lang.String,java.lang.Object> options)
                   throws java.io.IOException
hostname - the remote hostport - the port of the remote host to connectoptions - the socket options
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.net.InetAddress address,
                          int port)
                   throws java.io.IOException
address - the remote host addressport - the remote host port
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.net.InetAddress address,
                          int port,
                          StreamSocketConfiguration socketConf)
                   throws java.io.IOException
address - the remote host addressport - the remote host portsocketConf - the socket configuration
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.net.InetAddress address,
                          int port,
                          java.util.Map<java.lang.String,java.lang.Object> options)
                   throws java.io.IOException
address - the remote host addressport - the remote host portoptions - the socket options
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.net.InetAddress address,
                          int port,
                          javax.net.ssl.SSLContext sslContext,
                          boolean sslOn)
                   throws java.io.IOException
address - the remote host nameport - the remote host portsslContext - the sslContext to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.net.InetAddress address,
                          int port,
                          StreamSocketConfiguration socketConf,
                          javax.net.ssl.SSLContext sslContext,
                          boolean sslOn)
                   throws java.io.IOException
address - the remote host nameport - the remote host portsocketConf - the socket configurationsslContext - the sslContext to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.net.InetAddress address,
                          int port,
                          java.util.Map<java.lang.String,java.lang.Object> options,
                          javax.net.ssl.SSLContext sslContext,
                          boolean sslOn)
                   throws java.io.IOException
address - the remote host nameport - the remote host portoptions - the socket optionssslContext - the sslContext to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.lang.String hostname,
                          int port,
                          javax.net.ssl.SSLContext sslContext,
                          boolean sslOn)
                   throws java.io.IOException
hostname - the remote host nameport - the remote host portsslContext - the sslContext to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
    * @throws IOException If some other I/O error occurs
java.io.IOException
public BlockingConnection(java.lang.String hostname,
                          int port,
                          StreamSocketConfiguration socketConf,
                          javax.net.ssl.SSLContext sslContext,
                          boolean sslOn)
                   throws java.io.IOException
hostname - the remote host nameport - the remote host portsocketConf - the socket configurationsslContext - the sslContext to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs
public BlockingConnection(java.lang.String hostname,
                          int port,
                          java.util.Map<java.lang.String,java.lang.Object> options,
                          javax.net.ssl.SSLContext sslContext,
                          boolean sslOn)
                   throws java.io.IOException
hostname - the remote host nameport - the remote host portoption - the socket optionssslContext - the sslContext to usesslOn - true, activate SSL mode. false, ssl can be activated by user (see IConnection.activateSecuredMode())
java.io.IOException - If some other I/O error occurs| Method Detail | 
|---|
public byte readByte()
              throws java.io.IOException,
                     ClosedConnectionException,
                     java.net.SocketTimeoutException
readByte in interface IDataSourcereadByte in interface IBlockingConnectionreadByte in interface IConnectionjava.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 occurspublic final void setReceiveTimeoutMillis(long timeout)
setReceiveTimeoutMillis in interface IBlockingConnectiontimeout - the timeout in millis
public java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter)
                                                throws java.io.IOException,
                                                       ClosedConnectionException,
                                                       java.net.SocketTimeoutException
IBlockingConnection.readByteBufferByDelimiter(String, int) method is generally preferable 
 
readByteBufferByDelimiter in interface IBlockingConnectionreadByteBufferByDelimiter 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
public java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter,
                                                       int maxLength)
                                                throws java.io.IOException,
                                                       ClosedConnectionException,
                                                       java.net.SocketTimeoutException,
                                                       MaxReadSizeExceededException
readByteBufferByDelimiter in interface IBlockingConnectionreadByteBufferByDelimiter in interface IConnectiondelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
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
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
public java.nio.ByteBuffer[] readByteBufferByDelimiter(java.lang.String delimiter,
                                                       java.lang.String encoding,
                                                       int maxLength)
                                                throws java.io.IOException,
                                                       ClosedConnectionException,
                                                       MaxReadSizeExceededException
readByteBufferByDelimiter in interface IConnectiondelimiter - the delimiterencoding - the encoding of the delimitermaxLength - 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
public java.nio.ByteBuffer[] readByteBufferByLength(int length)
                                             throws java.io.IOException,
                                                    ClosedConnectionException,
                                                    java.net.SocketTimeoutException
readByteBufferByLength in interface IBlockingConnectionreadByteBufferByLength 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
public byte[] readBytesByDelimiter(java.lang.String delimiter)
                            throws java.io.IOException,
                                   ClosedConnectionException,
                                   java.net.SocketTimeoutException
IBlockingConnection.readBytesByDelimiter(String, int) method is generally preferable  
 
readBytesByDelimiter in interface IBlockingConnectionreadBytesByDelimiter 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
public byte[] readBytesByDelimiter(java.lang.String delimiter,
                                   int maxLength)
                            throws java.io.IOException,
                                   ClosedConnectionException,
                                   java.net.SocketTimeoutException,
                                   MaxReadSizeExceededException
readBytesByDelimiter in interface IDataSourcereadBytesByDelimiter in interface IBlockingConnectionreadBytesByDelimiter in interface IConnectiondelimiter - the delimitermaxLength - the max length of bytes that should be read. If the limit is exceeded a MaxReadSizeExceededException will been thrown
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
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
public byte[] readBytesByDelimiter(java.lang.String delimiter,
                                   java.lang.String encoding,
                                   int maxLength)
                            throws java.io.IOException,
                                   ClosedConnectionException,
                                   MaxReadSizeExceededException
readBytesByDelimiter in interface IConnectiondelimiter - the delimiterencoding - the encoding of the delimitermaxLength - 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
public byte[] readBytesByLength(int length)
                         throws java.io.IOException,
                                ClosedConnectionException,
                                java.net.SocketTimeoutException
readBytesByLength in interface IDataSourcereadBytesByLength in interface IBlockingConnectionreadBytesByLength 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
public double readDouble()
                  throws java.io.IOException,
                         ClosedConnectionException,
                         java.net.SocketTimeoutException
readDouble in interface IDataSourcereadDouble in interface IBlockingConnectionreadDouble in interface IConnectionjava.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
public int readInt()
            throws java.io.IOException,
                   ClosedConnectionException,
                   java.net.SocketTimeoutException
readInt in interface IDataSourcereadInt in interface IBlockingConnectionreadInt in interface IConnectionjava.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
public short readShort()
                throws java.io.IOException,
                       ClosedConnectionException,
                       java.net.SocketTimeoutException
readShort in interface IDataSourcejava.io.IOException - If some other I/O error occurs
ClosedConnectionException
java.net.SocketTimeoutException
public final int read(java.nio.ByteBuffer buffer)
               throws java.io.IOException
read in interface java.nio.channels.ReadableByteChanneljava.io.IOException
public long readLong()
              throws java.io.IOException,
                     ClosedConnectionException,
                     java.net.SocketTimeoutException
readLong in interface IDataSourcereadLong in interface IBlockingConnectionreadLong in interface IConnectionjava.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
public java.lang.String readStringByDelimiter(java.lang.String delimiter)
                                       throws java.io.IOException,
                                              ClosedConnectionException,
                                              java.io.UnsupportedEncodingException,
                                              java.net.SocketTimeoutException
IBlockingConnection.readStringByDelimiter(String, int) method is generally preferable
readStringByDelimiter in interface IDataSourcereadStringByDelimiter in interface IBlockingConnectionreadStringByDelimiter in interface IConnectiondelimiter - 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
public 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 IDataSourcereadStringByDelimiter in interface IBlockingConnectionreadStringByDelimiter in interface IConnectiondelimiter - the delimitermaxLength - 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
java.net.SocketTimeoutException - If the receive timeout has been reached
java.io.UnsupportedEncodingException - if the default encoding is not supported
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
public java.lang.String readStringByDelimiter(java.lang.String delimiter,
                                              java.lang.String encoding)
                                       throws java.io.IOException,
                                              ClosedConnectionException,
                                              java.io.UnsupportedEncodingException,
                                              java.net.SocketTimeoutException
IBlockingConnection.readStringByDelimiter(String, String) method is generally preferable
readStringByDelimiter in interface IBlockingConnectionreadStringByDelimiter 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
public 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 IDataSourcereadStringByDelimiter in interface IBlockingConnectionreadStringByDelimiter in interface IConnectiondelimiter - 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
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
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
public int getIndexOf(java.lang.String str)
               throws java.io.IOException,
                      ClosedConnectionException,
                      java.net.SocketTimeoutException
getIndexOf in interface IBlockingConnectiongetIndexOf 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
public int getIndexOf(java.lang.String str,
                      int maxLength)
               throws java.io.IOException,
                      ClosedConnectionException,
                      MaxReadSizeExceededException,
                      java.net.SocketTimeoutException
getIndexOf in interface IBlockingConnectiongetIndexOf 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
java.net.SocketTimeoutException - If the receive timeout has been reached
MaxReadSizeExceededException - If the max read length has been exceeded and the delimiter hasn’t been found
public int getIndexOf(java.lang.String str,
                      java.lang.String encoding,
                      int maxLength)
               throws java.io.IOException,
                      ClosedConnectionException,
                      MaxReadSizeExceededException
getIndexOf in interface IConnectionstr - any stringencoding - the encoding of the 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
public java.lang.String readStringByLength(int length)
                                    throws java.io.IOException,
                                           ClosedConnectionException,
                                           java.net.SocketTimeoutException
readStringByLength in interface IDataSourcereadStringByLength in interface IBlockingConnectionreadStringByLength 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
public java.lang.String readStringByLength(int length,
                                           java.lang.String encoding)
                                    throws java.io.IOException,
                                           ClosedConnectionException,
                                           java.net.SocketTimeoutException
readStringByLength in interface IDataSourcereadStringByLength in interface IBlockingConnectionreadStringByLength in interface IConnectionlength - 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
public IBlockingConnection setOption(java.lang.String name,
                                     java.lang.Object value)
                              throws java.io.IOException
setOption in interface IBlockingConnectionsetOption in interface IConnectionname - the name of the optionvalue - the value of the option
java.io.IOException - In an I/O error occurspublic final int getPendingWriteDataSize()
getPendingWriteDataSize in interface IConnection
public final void close()
                 throws java.io.IOException
close in interface java.io.Closeableclose in interface java.nio.channels.Channeljava.io.IOExceptionpublic final boolean isOpen()
IDataHandler.onData(INonBlockingConnection)
isOpen in interface java.nio.channels.ChannelisOpen in interface IConnection
public void suspendRead()
                 throws java.io.IOException
suspendRead in interface IConnectionjava.io.IOException - If some other I/O error occurs
public void resumeRead()
                throws java.io.IOException
resumeRead in interface IConnectionjava.io.IOException - If some other I/O error occurs
public void flush()
           throws ClosedConnectionException,
                  java.io.IOException
flush in interface java.io.Flushableflush in interface IConnectionClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurspublic final void setFlushmode(IConnection.FlushMode flushMode)
flushMode - the flushmodepublic final IConnection.FlushMode getFlushmode()
public void setIdleTimeoutSec(int timeoutInSec)
setIdleTimeoutSec in interface IConnectiontimeoutInSec - idle timeout in secpublic void setConnectionTimeoutSec(int timeoutSec)
setConnectionTimeoutSec in interface IConnectiontimeoutSec - the connection timeout in secpublic int getConnectionTimeoutSec()
getConnectionTimeoutSec in interface IConnectionpublic int getIdleTimeoutSec()
getIdleTimeoutSec in interface IConnectionpublic final java.lang.String getDefaultEncoding()
getDefaultEncoding in interface IConnectionpublic final void setDefaultEncoding(java.lang.String defaultEncoding)
setDefaultEncoding in interface IConnectiondefaultEncoding - the default encodingpublic final void setAutoflush(boolean autoflush)
setAutoflush in interface IConnectionautoflush - true if autoflush should be activatedpublic final boolean getAutoflush()
getAutoflush in interface IConnectionpublic final java.lang.String getId()
getId in interface IConnectionpublic final java.net.InetAddress getLocalAddress()
getLocalAddress in interface IConnectionpublic final int getLocalPort()
getLocalPort in interface IConnectionpublic final java.net.InetAddress getRemoteAddress()
getRemoteAddress in interface IConnectionpublic final int getRemotePort()
getRemotePort in interface IConnection
public void activateSecuredMode()
                         throws java.io.IOException
activateSecuredMode in interface IConnectionjava.io.IOException - If some other I/O error occurs
public final int write(java.lang.String s)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnections - the message to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(java.lang.String s,
                       java.lang.String encoding)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnections - the message to sendencoding - the encoding which should be used th encode the chars into byte (e.g. `US-ASCII` or `UTF-8`)
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(byte b)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionb - the byte to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(byte... bytes)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionbytes - the bytes to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(byte[] bytes,
                       int offset,
                       int length)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionbytes - 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.
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final long write(java.nio.ByteBuffer[] buffers)
                 throws ClosedConnectionException,
                        java.io.IOException
IConnection.INITIAL_AUTOFLUSH) the behaviour is
 according to the WritableByteChannel specification. In case of
 user managed flushing (autoflush is off) the passed over buffers will
 only be queued internally and written after flushing the connection.
write in interface java.nio.channels.GatheringByteChannelwrite in interface IDataSinkwrite in interface IConnectionbuffers - the bytes to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(java.nio.ByteBuffer buffer)
                throws ClosedConnectionException,
                       java.io.IOException
IConnection.INITIAL_AUTOFLUSH) the behaviour is
 according to the WritableByteChannel specification. In case of
 user managed flushing (autoflush is off) the passed over buffers will
 only be queued internally and written after flushing the connection.
write in interface java.nio.channels.WritableByteChannelwrite in interface IDataSinkwrite in interface IConnectionbuffer - the bytes to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(int i)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectioni - the int value to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(short s)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinks - the short value to write
java.io.IOException - If some other I/O error occurs
ClosedConnectionException
public final int write(long l)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectionl - the int value to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final int write(double d)
                throws ClosedConnectionException,
                       java.io.IOException
write in interface IDataSinkwrite in interface IConnectiond - the int value to send
ClosedConnectionException - if the underlying channel is closed
java.io.IOException - If some other I/O error occurs
public final long write(java.nio.ByteBuffer[] srcs,
                        int offset,
                        int length)
                 throws java.io.IOException
write in interface java.nio.channels.GatheringByteChanneljava.io.IOExceptionpublic int indexOf(java.lang.String str)
str - any string
public final java.lang.Object attach(java.lang.Object obj)
attach in interface IConnectionpublic final java.lang.Object attachment()
attachment in interface IConnectionpublic final void setAttachment(java.lang.Object obj)
setAttachment in interface IConnectionobj - The object to be attached; may be nullpublic final java.lang.Object getAttachment()
getAttachment in interface IConnectionpublic void markReadPosition()
markReadPosition in interface IConnectionpublic void markWritePosition()
 ...
 con.setAutoflush(false);
 con.markWritePosition();  // mark current position
 con.write((int) 0);       // write "emtpy" length field
 int written = con.write("hello world");
 written += con.write(" it’s nice to be here");
 ...
 con.resetToWriteMark();  // return to length field position
 con.write(written);      // and update it
 con.flush(); // flush (marker will be removed implicit)
…    * 
markWritePosition in interface IConnectionpublic boolean resetToWriteMark()
resetToWriteMark in interface IConnectionpublic boolean resetToReadMark()
resetToReadMark in interface IConnectionpublic void removeReadMark()
removeReadMark in interface IConnectionpublic void removeWriteMark()
removeWriteMark in interface IConnectionpublic void onWritten()
public void onWriteException(java.io.IOException ioException)
public final java.lang.Object getOption(java.lang.String name)
                                 throws java.io.IOException
getOption in interface IConnectionname - the name of the option
java.io.IOException - In an I/O error occurspublic final java.util.Map<java.lang.String,java.lang.Class> getOptions()
getOptions in interface IConnectionpublic java.lang.String toString()
toString in class java.lang.Object
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||