public static int sendmmsg( int fd, NativeDatagramPacketArray.NativeDatagramPacket[] msgs, int offset, int len) throws IOException { int res = sendmmsg0(fd, msgs, offset, len); if (res >= 0) { return res; } return ioResult("sendmmsg", res, SENDMMSG_CONNECTION_RESET_EXCEPTION, SENDMMSG_CLOSED_CHANNEL_EXCEPTION); }
SENDFILE_CONNECTION_RESET_EXCEPTION = newConnectionResetException("syscall:sendfile", ERRNO_EPIPE_NEGATIVE);
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 void disconnect() throws IOException { int res = disconnect(fd); if (res < 0) { throwConnectException("disconnect", FINISH_CONNECT_REFUSED_EXCEPTION, 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 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 static void epollCtlDel(int efd, final int fd) throws IOException { int res = epollCtlDel0(efd, fd); if (res < 0) { throw newIOException("epoll_ctl", res); } } private static native int epollCtlDel0(int efd, final int fd);
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; }
private static final long MAX_UINT32_T = 0xFFFFFFFFL; private static final NativeIoException SENDFILE_CONNECTION_RESET_EXCEPTION = newConnectionResetException("syscall:sendfile(...)", ERRNO_EPIPE_NEGATIVE); private static final ClosedChannelException SENDFILE_CLOSED_CHANNEL_EXCEPTION = ThrowableUtil.unknownStackTrace( new ClosedChannelException(), Native.class, "sendfile(...)");
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 static void epollCtlAdd(int efd, final int fd, final int flags) throws IOException { int res = epollCtlAdd0(efd, fd, flags); if (res < 0) { throw newIOException("epoll_ctl", res); } } private static native int epollCtlAdd0(int efd, final int fd, final int flags);
public final void disconnect() throws IOException { int res = disconnect(fd); if (res < 0) { throwConnectException("disconnect", FINISH_CONNECT_REFUSED_EXCEPTION, res); } }
SENDFILE_CONNECTION_RESET_EXCEPTION = newConnectionResetException("syscall:sendfile", ERRNO_EPIPE_NEGATIVE);
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); }
public static void epollCtlMod(int efd, final int fd, final int flags) throws IOException { int res = epollCtlMod0(efd, fd, flags); if (res < 0) { throw newIOException("epoll_ctl", res); } } private static native int epollCtlMod0(int efd, final int fd, final int flags);
public final boolean connect(SocketAddress socketAddress) throws IOException { int res; if (socketAddress instanceof InetSocketAddress) { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; NativeInetAddress address = NativeInetAddress.newInstance(inetSocketAddress.getAddress()); res = connect(fd, address.address, address.scopeId, inetSocketAddress.getPort()); } else if (socketAddress instanceof DomainSocketAddress) { DomainSocketAddress unixDomainSocketAddress = (DomainSocketAddress) socketAddress; res = connectDomainSocket(fd, unixDomainSocketAddress.path().getBytes(CharsetUtil.UTF_8)); } else { throw new Error("Unexpected SocketAddress implementation " + socketAddress); } if (res < 0) { if (res == ERRNO_EINPROGRESS_NEGATIVE) { // connect not complete yet need to wait for EPOLLOUT event return false; } throwConnectException("connect", CONNECT_REFUSED_EXCEPTION, res); } return true; }
private static final long MAX_UINT32_T = 0xFFFFFFFFL; private static final NativeIoException SENDFILE_CONNECTION_RESET_EXCEPTION = newConnectionResetException("syscall:sendfile(...)", ERRNO_EPIPE_NEGATIVE); private static final ClosedChannelException SENDFILE_CLOSED_CHANNEL_EXCEPTION = ThrowableUtil.unknownStackTrace( new ClosedChannelException(), Native.class, "sendfile(...)");
public final int read(ByteBuffer buf, int pos, int limit) throws IOException { int res = read(fd, buf, pos, limit); if (res > 0) { return res; } if (res == 0) { return -1; } return ioResult("read", res, READ_CONNECTION_RESET_EXCEPTION, READ_CLOSED_CHANNEL_EXCEPTION); }
public final void listen(int backlog) throws IOException { int res = listen(fd, backlog); if (res < 0) { throw newIOException("listen", res); } }
public final boolean connect(SocketAddress socketAddress) throws IOException { int res; if (socketAddress instanceof InetSocketAddress) { InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; NativeInetAddress address = NativeInetAddress.newInstance(inetSocketAddress.getAddress()); res = connect(fd, address.address, address.scopeId, inetSocketAddress.getPort()); } else if (socketAddress instanceof DomainSocketAddress) { DomainSocketAddress unixDomainSocketAddress = (DomainSocketAddress) socketAddress; res = connectDomainSocket(fd, unixDomainSocketAddress.path().getBytes(CharsetUtil.UTF_8)); } else { throw new Error("Unexpected SocketAddress implementation " + socketAddress); } if (res < 0) { if (res == ERRNO_EINPROGRESS_NEGATIVE) { // connect not complete yet need to wait for EPOLLOUT event return false; } throwConnectException("connect", CONNECT_REFUSED_EXCEPTION, res); } return true; }