Code examples for SelectionKey

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.
46:	if (sk.isValid() && sk.isWritable()) { 
-
48:	sk.interestOps(sk.interestOps() & ~SelectionKey.OP_WRITE); 
49:	SelectionHandler handler = (SelectionHandler) sk.attachment(); 
Full Snippet Info
7
CodeRank
56:	assertTrue(key.isValid()); 
57:	assertFalse(key.isReadable()); 
58:	assertEquals(0,key.readyOps()); 
-
64:	assertTrue(key.isValid()); 
65:	assertFalse(key.isReadable()); 
66:	assertEquals(0,key.readyOps()); 
-
76:	assertTrue(key.isValid()); 
77:	assertTrue(key.isReadable()); 
78:	assertEquals(1,key.readyOps()); 
-
84:	assertTrue(key.isValid()); 
85:	assertTrue(key.isReadable()); 
86:	assertEquals(1,key.readyOps()); 
-
97:	assertTrue(key.isValid()); 
98:	assertTrue(key.isReadable()); 
99:	assertEquals(1,key.readyOps()); 
-
105:	assertTrue(key.isValid()); 
106:	assertTrue(key.isReadable()); 
107:	assertEquals(1,key.readyOps()); 
-
113:	assertTrue(key.isValid()); 
114:	assertTrue(key.isReadable()); 
115:	assertEquals(1,key.readyOps()); 
-
121:	assertTrue(key.isValid()); 
122:	assertTrue(key.isReadable()); 
123:	assertEquals(1,key.readyOps()); 
-
126:	key.interestOps(SelectionKey.OP_READ|SelectionKey.OP_WRITE); 
-
130:	assertTrue(key.isValid()); 
131:	assertTrue(key.isWritable()); 
132:	assertFalse(key.isReadable()); 
133:	assertEquals(SelectionKey.OP_WRITE,key.readyOps()); 
Full Snippet Info
7
CodeRank
132:	return (SocketChannel) key.channel(); 
-
136:	SocketChannel channel = (SocketChannel) key.channel(); 
-
142:	key.attach(null); 
143:	key.cancel(); 
-
163:	if (key.attachment() == null) { 
-
165:	key.attach(request); 
-
167:	request = (Receive) key.attachment(); 
-
183:	key.interestOps(SelectionKey.OP_READ); 
Full Snippet Info
7
CodeRank
46:	if (sk.isValid() && sk.isReadable()) { 
-
48:	SelectionHandler handler = (SelectionHandler) sk.attachment(); 
Full Snippet Info
7
CodeRank
84:	int ops = key.readyOps(); 
85:	key.interestOps(key.interestOps() & ~ops); 
-
88:	if ( !key.isValid() ) throw new IOException("Key is not valid, it must have been cancelled."); 
89:	if ( key.isConnectable() ) { 
-
92:	if ( current != null ) key.interestOps(key.interestOps() | SelectionKey.OP_WRITE); 
-
96:	key.interestOps(key.interestOps() | SelectionKey.OP_CONNECT); 
-
99:	} else if ( key.isWritable() ) { 
-
105:	key.interestOps(key.interestOps() | SelectionKey.OP_READ); 
-
116:	key.interestOps(key.interestOps()|SelectionKey.OP_WRITE); 
-
118:	} else if ( key.isReadable() ) { 
-
124:	key.interestOps(key.interestOps() | SelectionKey.OP_READ); 
Full Snippet Info
7
CodeRank
140:	key.interestOps(SelectionKey.OP_WRITE); 
-
155:	if (!key.isValid()) { 
156:	key.cancel(); 
-
186:	key.cancel(); 
187:	key.attach(null); 
-
251:	if (!key.isConnectable() || !transport.finishConnect()) { 
Full Snippet Info
6
CodeRank
500:	if (this.selectionKey.isValid()) { 
-
504:	this.selectionKey.cancel(); 
-
513:	.interestOps()) 
-
519:	this.selectionKey.interestOps(getInterestOperations()); 
-
525:	this.selectionKey = register(this.selectionKey.selector()); 
-
531:	this.selectionKey = register(this.selectionKey.selector()); 
Full Snippet Info
6
CodeRank
200:	if (!key.isValid()) { 
-
202:	key.cancel(); 
-
207:	boolean connectable = key.isConnectable(); 
208:	boolean readable = key.isReadable(); 
209:	boolean writable = key.isWritable(); 
-
213:	key.cancel(); 
-
221:	key.interestOps(getInterestOps()); 
-
223:	key.cancel(); //XXX is this ok? 
Full Snippet Info
6
CodeRank
173:	if (selKey.isValid() && selKey.isAcceptable()) { 
-
175:	ServerSocketChannel ssChannel = (ServerSocketChannel) selKey.channel(); 
-
194:	if (selKey.isValid() && selKey.isConnectable()) { 
-
196:	SocketChannel sChannel = (SocketChannel) selKey.channel(); 
-
199:	selKey.cancel(); 
-
207:	selKey.cancel(); 
-
212:	selKey.cancel(); 
-
218:	if (selKey.isValid() && selKey.isReadable()) { 
219:	SocketChannel sChannel = (SocketChannel) selKey.channel(); 
-
225:	selKey.cancel(); 
-
231:	if (selKey.isValid() && selKey.isWritable()) { 
232:	SocketChannel sChannel = (SocketChannel) selKey.channel(); 
-
238:	selKey.cancel(); 
Full Snippet Info
6
CodeRank
58:	session.setKey(key); 
-
61:	SocketChannel channel = (SocketChannel) key.channel(); 
-
70:	key.cancel(); 
Full Snippet Info
6
CodeRank
73:	if (((ReadableByteChannel)key.channel()).read(readBuffer) == -1) 
-
86:	closeAfterWrite = writePb(key); 
-
89:	key.channel().close(); 
90:	key.cancel(); 
Full Snippet Info
6
CodeRank
501:	Connection connection = (Connection)key.attachment(); 
-
506:	int count = ((SocketChannel)key.channel()).read(buf); 
Full Snippet Info
6
CodeRank
82:	if (key.isAcceptable()) { 
83:	ServerSocketChannel server = (ServerSocketChannel) key.channel(); 
-
90:	} else if (key.isReadable()) { 
-
97:	SocketChannel sc = (SocketChannel)key.channel(); 
Full Snippet Info
6
CodeRank
23:	if (selectionKey.isValid()) { 
24:	if (selectionKey.isReadable() || selectionKey.isWritable()) { 
-
26:	.setInterestOps(selectionKey, (selectionKey 
27:	.interestOps() & (~selectionKey.readyOps()))); 
-
29:	attachment)); 
-
32:	attachment.cancelledKey(kuraokami, selectionKey); 
Full Snippet Info
6
CodeRank
71:	session.setKey(key); 
72:	SocketChannel channel = (SocketChannel) key.channel(); 
-
81:	key.cancel(); 
Full Snippet Info
6
CodeRank
305:	boolean valid = _key != null && _key.isValid(); 
306:	int keyInterests = valid ? _key.interestOps() : -1; 
307:	int keyReadiness = valid ? _key.readyOps() : -1; 
Full Snippet Info
6
CodeRank
89:	SocketChannel channel = ((SocketChannel) key.channel()); 
-
91:	if (key.attachment() instanceof MappedByteBuffer) { 
-
93:	} else if (key.attachment() instanceof DynamicByteBuffer) { 
-
103:	MappedByteBuffer mbb = (MappedByteBuffer) key.attachment(); 
-
118:	DynamicByteBuffer dbb = (DynamicByteBuffer) key.attachment(); 
Full Snippet Info
6
CodeRank
57:	key.selector().close(); 
58:	key.channel().close(); 
Full Snippet Info
6
CodeRank
269:	s = "Att: " + (sk.attachment() == null ? "no" : "yes"); 
270:	s += ", Read: " + sk.isReadable(); 
271:	s += ", Acpt: " + sk.isAcceptable(); 
272:	s += ", Cnct: " + sk.isConnectable(); 
273:	s += ", Wrt: " + sk.isWritable(); 
274:	s += ", Valid: " + sk.isValid(); 
275:	s += ", Ops: " + sk.interestOps(); 
Full Snippet Info
6
CodeRank
30:	writeSelectionKey.cancel(); 
Full Snippet Info
6
CodeRank