Java Code Examples for io.netty.channel.DefaultFileRegion#open()

The following examples show how to use io.netty.channel.DefaultFileRegion#open() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BsdSocket.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
long sendFile(DefaultFileRegion src, long baseOffset, long offset, long length) throws IOException {
    // Open the file-region as it may be created via the lazy constructor. This is needed as we directly access
    // the FileChannel field via JNI.
    src.open();

    long res = sendFile(intValue(), src, baseOffset, offset, length);
    if (res >= 0) {
        return res;
    }
    return ioResult("sendfile", (int) res, SENDFILE_CONNECTION_RESET_EXCEPTION, SENDFILE_CLOSED_CHANNEL_EXCEPTION);
}
 
Example 2
Source File: LinuxSocket.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
long sendFile(DefaultFileRegion src, long baseOffset, long offset, long length) throws IOException {
    // Open the file-region as it may be created via the lazy constructor. This is needed as we directly access
    // the FileChannel field via JNI.
    src.open();

    long res = sendFile(intValue(), src, baseOffset, offset, length);
    if (res >= 0) {
        return res;
    }
    return ioResult("sendfile", (int) res, SENDFILE_CONNECTION_RESET_EXCEPTION, SENDFILE_CLOSED_CHANNEL_EXCEPTION);
}
 
Example 3
Source File: Native.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
public static long sendfile(
        int dest, DefaultFileRegion src, long baseOffset, long offset, long length) throws IOException {
    // Open the file-region as it may be created via the lazy constructor. This is needed as we directly access
    // the FileChannel field directly via JNI
    src.open();

    long res = sendfile0(dest, src, baseOffset, offset, length);
    if (res >= 0) {
        return res;
    }
    return ioResult("sendfile", (int) res, CONNECTION_RESET_EXCEPTION_SENDFILE);
}