Register a channel and hand it its per-connection state
Register a channel and hand it its per-connection state
Answer
client.configureBlocking(false); SelectionKey key = client.register(selector, SelectionKey.OP_READ); key.attach(response.duplicate());
register() lives on the channel and requires non-blocking mode first. The attachment carries this connection state; duplicate() gives this client its own position and limit over the one shared response buffer.
Harold 4e ch11 §Readiness Selection