IConnection
Description
- Derived from
Base interface for network connections.
Network connections provided by IConnection implementations are connection oriented and reliable.
- See also
Public / Methods
Close
Performs a graceful shutdown of the connection.
After gracefully closing a connection, its local endpoint might remain unusable for some time (for example, see the TIME_WAIT state of TCP/IP). Calling this method more than once is allowed but will have no effect. It will be called implicitly when the connection is disposed. However, calling Close explicitly allows the caller to handle the IOException, if thrown.
Connections to well-behaving clients should be terminated with a graceful shutdown.
- IOException
-
If an I/O error has occurred.
Discard
Discards the connection.
When discarding a connection, the remote peer receives an error (and will throw an IOException, for example). After a connection has been discarded, its local endpoint will be reusable immediately.
Connections to misbehaving clients should be terminated with a forceful discard.
- IOException
-
If an I/O error has occurred.
Receive
Receives a sequence of bytes from this network connection.
The number of bytes to receive (N
) is the number of ByteBuffer.Remaining bytes in the given ByteBuffer. The received bytes will be written to the buffer in beginning at its current ByteBuffer.Position, incrementing it while receiving. If necessary, the method will block until all data has been received.
- IOException
-
If an I/O error has occurred.
Send
Sends a sequence of bytes over this network connection.
The number of bytes to send (N
) is the number of ByteBuffer.Remaining bytes in the given ByteBuffer. The bytes to send will be read from the buffer in beginning at its current ByteBuffer.Position, incrementing it while sending. If necessary, the method will block until all data has been sent (or buffered) by the network layer.
- IOException
-
If an I/O error has occurred.