Code examples for SocketChannel

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.
53:	socket.configureBlocking(false); 
54:	outstr = new SocketOutputStream(socket); 
55:	instr = new SocketInputStream(socket); 
-
59:	InetSocketAddress localSocketAddress = (InetSocketAddress) socket.socket().getLocalSocketAddress(); 
-
61:	InetSocketAddress remoteSocketAddress = (InetSocketAddress) socket.socket().getRemoteSocketAddress(); 
Full Snippet Info
8
CodeRank
138:	assertFalse(this.channel1.isConnected());// not connected 
139:	this.channel1.configureBlocking(false); 
140:	assertFalse(this.channel1.connect(localAddr1)); 
141:	assertFalse(this.channel1.isConnected()); 
142:	assertTrue(this.channel1.isConnectionPending()); 
-
144:	assertTrue(this.channel1.isConnected()); 
145:	this.channel1.close(); 
146:	assertFalse(this.channel1.isConnected()); 
-
219:	assertTrue(this.channel1.isConnected()); 
220:	assertFalse(this.channel1.isConnectionPending()); 
221:	assertTrue(this.channel1.isOpen()); 
-
229:	assertTrue(this.channel1.isOpen()); 
-
231:	connected = this.channel1.finishConnect(); 
Full Snippet Info
7
CodeRank
33:	channel.configureBlocking(false); 
-
35:	socket = new AsynchronousSocket(channel); 
36:	IOLoop.INSTANCE.addHandler(channel, socket, SelectionKey.OP_READ, ByteBuffer.allocate(1024)); 
Full Snippet Info
6
CodeRank
136:	socketChannel.configureBlocking(false); 
137:	socketChannel.socket().setSendBufferSize(getTxBufSize()); 
138:	socketChannel.socket().setReceiveBufferSize(getRxBufSize()); 
139:	socketChannel.socket().setSoTimeout((int)getTimeout()); 
140:	socketChannel.socket().setSoLinger(getSoLingerOn(),getSoLingerOn()?getSoLingerTime():0); 
141:	socketChannel.socket().setTcpNoDelay(getTcpNoDelay()); 
142:	socketChannel.socket().setKeepAlive(getSoKeepAlive()); 
143:	socketChannel.socket().setReuseAddress(getSoReuseAddress()); 
144:	socketChannel.socket().setOOBInline(getOoBInline()); 
145:	socketChannel.socket().setSoLinger(getSoLingerOn(),getSoLingerTime()); 
146:	socketChannel.socket().setTrafficClass(getSoTrafficClass()); 
-
248:	if ( socketChannel.connect(addr) ) { 
-
250:	socketChannel.register(getSelector(), SelectionKey.OP_WRITE, this); 
-
252:	socketChannel.register(getSelector(), SelectionKey.OP_CONNECT, this); 
Full Snippet Info
6
CodeRank
147:	return "InetClientSocket[" + ch.toString() 
148:	+ " open="+ch.isOpen() 
149:	+ " addr="+ch.socket().getLocalSocketAddress() 
150:	+ " remote="+ch.socket().getRemoteSocketAddress() 
Full Snippet Info
7
CodeRank
93:	if (sc != null) sc.close(); 
Full Snippet Info
6
CodeRank
96:	if (ioLoop.hasKeepAliveTimeout(channel)) { 
-
106:	channel.write(mbb); 
-
109:	Closeables.closeQuietly(channel); 
-
124:	bytesWritten = channel.write(toSend); 
-
127:	Closeables.closeQuietly(channel); 
Full Snippet Info
6
CodeRank
127:	return socketChannel_.isOpen() && socketChannel_.isConnected(); 
Full Snippet Info
6
CodeRank
62:	client.configureBlocking(false); 
63:	client.register(selector, SelectionKey.OP_READ | SelectionKey.OP_WRITE); 
-
67:	client.write(dst); 
Full Snippet Info
6
CodeRank
77:	_channel.close(); 
Full Snippet Info
6
CodeRank
74:	return socketChannel.isOpen(); 
Full Snippet Info
6
CodeRank
162:	logger.info("New connection from " + channel.socket().getInetAddress().getHostAddress() 
-
165:	channel.close(); 
-
169:	channel.configureBlocking(false); 
170:	Socket socket = channel.socket(); 
-
184:	channel.close(); 
Full Snippet Info
6
CodeRank
80:	Socket socket = socketChannel.socket(); 
-
86:	socketChannel.read(buffer); 
-
93:	socketChannel.write(encode(sb.toString())); 
-
105:	fileChannel.transferTo(0, fileChannel.size(), socketChannel); 
-
112:	socketChannel.close(); 
Full Snippet Info
6
CodeRank
105:	if (sc == null || !sc.isOpen()) { 
Full Snippet Info
6
CodeRank
73:	if (!socketChannel.isConnected()) throw new IOException("Socket must already be connected"); 
-
82:	socketChannel.configureBlocking(false); 
-
85:	Socket socket = socketChannel.socket(); 
Full Snippet Info
6
CodeRank
323:	assert channel == null || !channel.isOpen() 
Full Snippet Info
6
CodeRank
65:	n = channel.read(dst); 
-
71:	channel.close(); 
Full Snippet Info
6
CodeRank
43:	client.configureBlocking(false); 
-
45:	SelectorManager.getSelectorManager().register(client, handler, SelectionKey.OP_READ); 
Full Snippet Info
6
CodeRank
143:	assertFalse(this.channel1.isConnected());// not connected 
144:	this.channel1.configureBlocking(false); 
145:	assertFalse(this.channel1.connect(localAddr1)); 
146:	assertFalse(this.channel1.isConnected()); 
147:	assertTrue(this.channel1.isConnectionPending()); 
-
149:	assertTrue(this.channel1.isConnected()); 
150:	this.channel1.close(); 
151:	assertFalse(this.channel1.isConnected()); 
-
224:	assertTrue(this.channel1.isConnected()); 
225:	assertFalse(this.channel1.isConnectionPending()); 
226:	assertTrue(this.channel1.isOpen()); 
-
234:	assertTrue(this.channel1.isOpen()); 
-
236:	connected = this.channel1.finishConnect(); 
Full Snippet Info
6
CodeRank
44:	int bytesRead = socketChannel.read(buffer); 
-
47:	throw new IOException("Reached an EOL or something bizzare occured. Reading from: " + socketChannel.socket().getInetAddress() + " BufferSizeRemaining: " + buffer.remaining()); 
Full Snippet Info
6
CodeRank