Lines Matching refs:buffer

118     public int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException {
120 final int position = buffer.position();
122 if (buffer.isDirect()) {
123 bytesRead = preadBytes(fd, buffer, position, buffer.remaining(), offset);
125 bytesRead = preadBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), offset);
128 maybeUpdateBufferPosition(buffer, position, bytesRead);
135 private native int preadBytes(FileDescriptor fd, Object buffer, int bufferOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException;
136 public int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException {
138 final int position = buffer.position();
140 if (buffer.isDirect()) {
141 bytesWritten = pwriteBytes(fd, buffer, position, buffer.remaining(), offset);
143 bytesWritten = pwriteBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), offset);
146 maybeUpdateBufferPosition(buffer, position, bytesWritten);
153 private native int pwriteBytes(FileDescriptor fd, Object buffer, int bufferOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException;
154 public int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException {
156 final int position = buffer.position();
158 if (buffer.isDirect()) {
159 bytesRead = readBytes(fd, buffer, position, buffer.remaining());
161 bytesRead = readBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining());
164 maybeUpdateBufferPosition(buffer, position, bytesRead);
171 private native int readBytes(FileDescriptor fd, Object buffer, int offset, int byteCount) throws ErrnoException, InterruptedIOException;
175 public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException {
177 final int position = buffer.position();
179 if (buffer.isDirect()) {
180 bytesReceived = recvfromBytes(fd, buffer, position, buffer.remaining(), flags, srcAddress);
182 bytesReceived = recvfromBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), flags, srcAddress);
185 maybeUpdateBufferPosition(buffer, position, bytesReceived);
192 private native int recvfromBytes(FileDescriptor fd, Object buffer, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException;
197 public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException {
199 final int position = buffer.position();
201 if (buffer.isDirect()) {
202 bytesSent = sendtoBytes(fd, buffer, position, buffer.remaining(), flags, inetAddress, port);
204 bytesSent = sendtoBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining(), flags, inetAddress, port);
207 maybeUpdateBufferPosition(buffer, position, bytesSent);
217 private native int sendtoBytes(FileDescriptor fd, Object buffer, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException;
218 private native int sendtoBytes(FileDescriptor fd, Object buffer, int byteOffset, int byteCount, int flags, SocketAddress address) throws ErrnoException, SocketException;
259 public int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException {
261 final int position = buffer.position();
262 if (buffer.isDirect()) {
263 bytesWritten = writeBytes(fd, buffer, position, buffer.remaining());
265 bytesWritten = writeBytes(fd, NioUtils.unsafeArray(buffer), NioUtils.unsafeArrayOffset(buffer) + position, buffer.remaining());
268 maybeUpdateBufferPosition(buffer, position, bytesWritten);
275 private native int writeBytes(FileDescriptor fd, Object buffer, int offset, int byteCount) throws ErrnoException, InterruptedIOException;
278 private static void maybeUpdateBufferPosition(ByteBuffer buffer, int originalPosition, int bytesReadOrWritten) {
280 buffer.position(bytesReadOrWritten + originalPosition);