This interface may also represent an SSL connection, see subtype SslConnection.

Write Queue

This connection maintains a queue of ByteBuffers to be written.
Append a ByteBuffer to the queue by queueWrite(ByteBuffer).
Queued data are not automatically written, you have to call write().
After write(), if getWriteQueueSize() does not reach 0,
the connection is temporarily un-writable, and you may call awaitWritable() before write() again.

Thread Safety

This class is generally not thread-safe. For example, if two threads call read() concurrently,
the behavior is undefined, and probably disastrous.
Usually, you'll use the connection executor
for all connection-related tasks, and they will be executed in serialized order.

close

Data in the write queue are abandoned. The TCP connection will be closed.

If `drainTimeout` is non-null and positive, we will attempt to drain the inbound
TCP bytes (till FIN is received) before we actually close the TCP connection.
This is to avoid the infamous TCP RST problem - if the connection is closed without
draining the inbound, the peer may not received the data we have sent.

The draining step is unnecessary if the app protocol is properly designed,
which knows that there's no inbound data at the time of close.

The draining step can also be skipped if FIN was seen in a previous read(),
or app wants to kill the connection immediately.