Lines Matching refs:buffer

133     public int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException {
135 final int position = buffer.position();
137 if (buffer.isDirect()) {
138 bytesRead = preadBytes(fd, buffer, position, buffer.remaining(), offset);
140 bytesRead = preadBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), offset);
143 maybeUpdateBufferPosition(buffer, position, bytesRead);
150 private native int preadBytes(FileDescriptor fd, Object buffer, int bufferOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException;
151 public int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException {
153 final int position = buffer.position();
155 if (buffer.isDirect()) {
156 bytesWritten = pwriteBytes(fd, buffer, position, buffer.remaining(), offset);
158 bytesWritten = pwriteBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), offset);
161 maybeUpdateBufferPosition(buffer, position, bytesWritten);
168 private native int pwriteBytes(FileDescriptor fd, Object buffer, int bufferOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException;
169 public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException {
171 final int position = buffer.position();
173 if (buffer.isDirect()) {
174 bytesRead = readBytes(fd, buffer, position, buffer.remaining());
176 bytesRead = readBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining());
179 maybeUpdateBufferPosition(buffer, position, bytesRead);
186 private native int readBytes(FileDescriptor fd, Object buffer, int offset, int byteCount) throws ErrnoException, InterruptedIOException;
190 public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException {
192 final int position = buffer.position();
194 if (buffer.isDirect()) {
195 bytesReceived = recvfromBytes(fd, buffer, position, buffer.remaining(), flags, srcAddress);
197 bytesReceived = recvfromBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), flags, srcAddress);
200 maybeUpdateBufferPosition(buffer, position, bytesReceived);
207 private native int recvfromBytes(FileDescriptor fd, Object buffer, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException;
212 public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException {
214 final int position = buffer.position();
216 if (buffer.isDirect()) {
217 bytesSent = sendtoBytes(fd, buffer, position, buffer.remaining(), flags, inetAddress, port);
219 bytesSent = sendtoBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), flags, inetAddress, port);
222 maybeUpdateBufferPosition(buffer, position, bytesSent);
232 private native int sendtoBytes(FileDescriptor fd, Object buffer, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException;
233 private native int sendtoBytes(FileDescriptor fd, Object buffer, int byteOffset, int byteCount, int flags, SocketAddress address) throws ErrnoException, SocketException;
274 public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException {
276 final int position = buffer.position();
277 if (buffer.isDirect()) {
278 bytesWritten = writeBytes(fd, buffer, position, buffer.remaining());
280 bytesWritten = writeBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining());
283 maybeUpdateBufferPosition(buffer, position, bytesWritten);
290 private native int writeBytes(FileDescriptor fd, Object buffer, int offset, int byteCount) throws ErrnoException, InterruptedIOException;
293 private static void maybeUpdateBufferPosition(ByteBuffer buffer, int originalPosition, int bytesReadOrWritten) {
295 buffer.position(bytesReadOrWritten + originalPosition);