Here you can find the source of ClientReadWithBlock(SocketChannel sc)
public static ByteBuffer ClientReadWithBlock(SocketChannel sc)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; public class Main { public static ByteBuffer ClientReadWithBlock(SocketChannel sc) { ByteBuffer buffer = ByteBuffer.allocate(1024); buffer.clear();/*from w w w. ja v a 2s .c o m*/ try { while (sc.read(buffer) < 1) ; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return buffer; } }