src/main/java/org/java_websocket/server/WebSocketServer.java
private boolean doRead(SelectionKey key, Iterator<SelectionKey> i) throws InterruptedException, IOException {
		WebSocketImpl conn = (WebSocketImpl) key.attachment();
		ByteBuffer buf = takeBuffer();
		if(conn.getChannel() == null){
			key.cancel();

			handleIOException( key, conn, new IOException() );
			return false;
		}
		try {
			if( SocketChannelIOHelper.read( buf, conn, conn.getChannel() ) ) {
				if( buf.hasRemaining() ) {
					conn.inQueue.put( buf );
					queue( conn );
					i.remove();
					if( conn.getChannel() instanceof WrappedByteChannel && ( (WrappedByteChannel) conn.getChannel() ).isNeedRead() ) {
						iqueue.add( conn );
					}
				} else {
					pushBuffer(buf);
				}
			} else {
				pushBuffer( buf );
			}
		} catch ( IOException e ) {
			pushBuffer( buf );
			throw e;
		}
		return true;
	}
private boolean doRead(SelectionKey key, Iterator<SelectionKey> i) throws InterruptedException, IOException {
		WebSocketImpl conn = (WebSocketImpl) key.attachment();
		ByteBuffer buf = takeBuffer();
		if(conn.getChannel() == null){
			key.cancel();

			handleIOException( key, conn, new IOException() );
			return false;
		}
		try {
			if( SocketChannelIOHelper.read( buf, conn, conn.getChannel() ) ) {
				if( buf.hasRemaining() ) {
					conn.inQueue.put( buf );
					queue( conn );
					i.remove();
					if( conn.getChannel() instanceof WrappedByteChannel && ( (WrappedByteChannel) conn.getChannel() ).isNeedRead() ) {
						iqueue.add( conn );
					}
				} else {
					pushBuffer(buf);
				}
			} else {
				pushBuffer( buf );
			}
		} catch ( IOException e ) {
			pushBuffer( buf );
			throw e;
		}
		return true;
	}
private boolean doRead ( SelectionKey key , Iterator < SelectionKey > i ) throws InterruptedException , IOException { WebSocketImpl conn = ( WebSocketImpl ) key . attachment ( ) ; ByteBuffer buf = takeBuffer ( ) ; if ( conn . getChannel ( ) == null ) { key . cancel ( ) ; handleIOException ( key , conn , new IOException ( ) ) ; return false ; } try { if ( SocketChannelIOHelper . read ( buf , conn , conn . getChannel ( ) ) ) { if ( buf . hasRemaining ( ) ) { conn . inQueue . put ( buf ) ; queue ( conn ) ; i . remove ( ) ; if ( conn . getChannel ( ) instanceof WrappedByteChannel && ( ( WrappedByteChannel ) conn . getChannel ( ) ) . isNeedRead ( ) ) { iqueue . add ( conn ) ; } } else { pushBuffer ( buf ) ; } } else { pushBuffer ( buf ) ; } } catch ( IOException e ) { pushBuffer ( buf ) ; throw e ; } return true ; }
Execute a read operation
@param key the selectionkey to read off
@param i the iterator for the selection keys
@return true, if the read was successful, or false if there was an error
@throws InterruptedException thrown by taking a buffer
@throws IOException if an error happened during read
Execute a read operation