Interface ISocket<I extends SelectableChannel & ReadableByteChannel,O extends SelectableChannel & WritableByteChannel>
-
- Type Parameters:
I- A channel which can be selected and read data fromO- A channel which can be selected and write data to
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
NioTcpSocket
public interface ISocket<I extends SelectableChannel & ReadableByteChannel,O extends SelectableChannel & WritableByteChannel> extends AutoCloseable
A facade to allow multiple channel implementations on the same type.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidclose()Formally closes the connectionvoidconnect(InetSocketAddress endpoint)Connects the underlying Socket to the endpoint.IgetReadableChannel()OgetWritableChannel()booleanisClosed()Checks if the connection has been closedbooleanisConnected()booleanisInputShutdown()Deprecated.booleanisOutputShutdown()Deprecated.
-
-
-
Method Detail
-
connect
void connect(InetSocketAddress endpoint) throws IOException
Connects the underlying Socket to the endpoint. This event must happen asynchronously. To notify the socket is connected (or it failed) useSelectionKey.OP_CONNECTin combination withisConnected().- Parameters:
endpoint- The Address to connect to- Throws:
IOException- When connection fails
-
isConnected
boolean isConnected()
- Returns:
trueif the connection is successfully established. Otherwisefalse.
-
getReadableChannel
I getReadableChannel()
-
getWritableChannel
O getWritableChannel()
-
close
void close() throws IOExceptionFormally closes the connection- Specified by:
closein interfaceAutoCloseable- Throws:
IOException- When the connection could not be closed
-
isClosed
boolean isClosed()
Checks if the connection has been closed- Returns:
- true if the connection is closing/closed
-
isInputShutdown
@Deprecated boolean isInputShutdown()
Deprecated.Checks if there will be no more data incoming- Returns:
- true if EOF has been found
-
isOutputShutdown
@Deprecated boolean isOutputShutdown()
Deprecated.Checks if no more data can be send on this socket- Returns:
- true if EOF has been send
-
-