public final int writeAddress(long address, int pos, int limit) throws IOException { int res = writeAddress(fd, address, pos, limit); if (res >= 0) { return res; } return ioResult("writeAddress", res, WRITE_ADDRESS_CONNECTION_RESET_EXCEPTION, WRITE_ADDRESS_CLOSED_CHANNEL_EXCEPTION); }
public final long writevAddresses(long memoryAddress, int length) throws IOException { long res = writevAddresses(fd, memoryAddress, length); if (res >= 0) { return res; } return ioResult("writevAddresses", (int) res, WRITEV_ADDRESSES_CONNECTION_RESET_EXCEPTION, WRITEV_ADDRESSES_CLOSED_CHANNEL_EXCEPTION); }
public final int readAddress(long address, int pos, int limit) throws IOException { int res = readAddress(fd, address, pos, limit); if (res > 0) { return res; } if (res == 0) { return -1; } return ioResult("readAddress", res, READ_ADDRESS_CONNECTION_RESET_EXCEPTION, READ_ADDRESS_CLOSED_CHANNEL_EXCEPTION); }
/** * @return [0] = read end, [1] = write end */ public static FileDescriptor[] pipe() throws IOException { long res = newPipe(); if (res < 0) { throw newIOException("newPipe", (int) res); } return new FileDescriptor[]{new FileDescriptor((int) (res >>> 32)), new FileDescriptor((int) res)}; }
public final int sendFd(int fdToSend) throws IOException { int res = sendFd(fd, fdToSend); if (res >= 0) { return res; } if (res == ERRNO_EAGAIN_NEGATIVE || res == ERRNO_EWOULDBLOCK_NEGATIVE) { // Everything consumed so just return -1 here. return -1; } throw newIOException("sendFd", res); }
public final InetSocketAddress localAddress() { byte[] addr = localAddress(fd); // addr may be null if getpeername failed. // See https://github.com/netty/netty/issues/3328 return addr == null ? null : address(addr, 0, addr.length); }
public final void listen(int backlog) throws IOException { int res = listen(fd, backlog); if (res < 0) { throw newIOException("listen", res); } }
public final int accept(byte[] addr) throws IOException { int res = accept(fd, addr); if (res >= 0) { return res; } if (res == ERRNO_EAGAIN_NEGATIVE || res == ERRNO_EWOULDBLOCK_NEGATIVE) { // Everything consumed so just return -1 here. return -1; } throw newIOException("accept", res); }
public static NativeIoException newConnectionResetException(String method, int errnoNegative) { NativeIoException exception = newIOException(method, errnoNegative); exception.setStackTrace(EmptyArrays.EMPTY_STACK_TRACE); return exception; }
public final InetSocketAddress remoteAddress() { byte[] addr = remoteAddress(fd); // addr may be null if getpeername failed. // See https://github.com/netty/netty/issues/3328 return addr == null ? null : address(addr, 0, addr.length); }
public final int recvFd() throws IOException { int res = recvFd(fd); if (res > 0) { return res; } if (res == 0) { return -1; } if (res == ERRNO_EAGAIN_NEGATIVE || res == ERRNO_EWOULDBLOCK_NEGATIVE) { // Everything consumed so just return -1 here. return 0; } throw newIOException("recvFd", res); }
public final boolean finishConnect() throws IOException { int res = finishConnect(fd); if (res < 0) { if (res == ERRNO_EINPROGRESS_NEGATIVE) { // connect still in progress return false; } throwConnectException("finishConnect", FINISH_CONNECT_REFUSED_EXCEPTION, res); } return true; }
public final void disconnect() throws IOException { int res = disconnect(fd); if (res < 0) { throwConnectException("disconnect", FINISH_CONNECT_REFUSED_EXCEPTION, res); } }
/** * Checks if the specified buffer has memory address or is composed of n(n <= IOV_MAX) NIO direct buffers. * (We check this because otherwise we need to make it a new direct buffer.) */ public static boolean isBufferCopyNeededForWrite(ByteBuf byteBuf) { return isBufferCopyNeededForWrite(byteBuf, IOV_MAX); }
/** * Return a cleared {@link IovArray} that can be used for writes in this {@link EventLoop}. */ IovArray cleanArray() { iovArray.clear(); return iovArray; }
/** * Returns {@code true} if the file descriptor is open. */ public boolean isOpen() { return !isClosed(state); }
/** * Free this {@link EpollEventArray}. Any usage after calling this method may segfault the JVM! */ void free() { Buffer.free(memory); memoryAddress = 0; }