// Path: src/main/java/com/wizzardo/epoll/Utils.java
//     public static int readInt(byte[] b, int offset) {
// //        if (b.length - offset < 4 || offset < 0)
// //            throw new IndexOutOfBoundsException("byte[].length = " + b.length + ", but offset = " + offset + " and we need 4 bytes");
// 
//         return ((b[offset] & 0xff) << 24) + ((b[offset + 1] & 0xff) << 16) + ((b[offset + 2] & 0xff) << 8) + ((b[offset + 3] & 0xff));
//     }
// 
// Path: src/main/java/com/wizzardo/epoll/Utils.java
//     public static int readShort(byte[] b, int offset) {
// //        if (b.length - offset < 2 || offset < 0)
// //            throw new IndexOutOfBoundsException("byte[].length = " + b.length + ", but offset = " + offset + " and we need 2 bytes");
// 
//         return ((b[offset] & 0xff) << 8) + ((b[offset + 1] & 0xff));
//     }


import com.wizzardo.tools.misc.Unchecked;
import com.wizzardo.tools.reflection.FieldReflection;
import com.wizzardo.tools.reflection.FieldReflectionFactory;
import com.wizzardo.tools.reflection.UnsafeTools;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.regex.Pattern;
import static com.wizzardo.epoll.Utils.readInt;
import static com.wizzardo.epoll.Utils.readShort;
    public void setTTL(long milliseconds) {
        ttl = milliseconds;
    }

    public long getTTL() {
        return ttl;
    }

    public void close() {
        synchronized (this) {
            if (running) {
                running = false;
                stopListening(scope);
                try {
                    join();
                } catch (InterruptedException ignored) {
                }
            }
        }
    }

    private void acceptConnections(byte[] buffer) throws IOException {
        int k;
        do {
            events.position(0);
            k = acceptConnections(scope, events.capacity() - 10);
            events.limit(k);
            events.get(buffer, 0, k);
//          eventCounter.addAndGet(k / 10);
            for (int j = 0; j < k; j += 10) {
// Path: src/main/java/com/wizzardo/epoll/Utils.java
//     public static int readInt(byte[] b, int offset) {
// //        if (b.length - offset < 4 || offset < 0)
// //            throw new IndexOutOfBoundsException("byte[].length = " + b.length + ", but offset = " + offset + " and we need 4 bytes");
// 
//         return ((b[offset] & 0xff) << 24) + ((b[offset + 1] & 0xff) << 16) + ((b[offset + 2] & 0xff) << 8) + ((b[offset + 3] & 0xff));
//     }
// 
// Path: src/main/java/com/wizzardo/epoll/Utils.java
//     public static int readShort(byte[] b, int offset) {
// //        if (b.length - offset < 2 || offset < 0)
// //            throw new IndexOutOfBoundsException("byte[].length = " + b.length + ", but offset = " + offset + " and we need 2 bytes");
// 
//         return ((b[offset] & 0xff) << 8) + ((b[offset + 1] & 0xff));
//     }


// Path: src/main/java/com/wizzardo/epoll/EpollCore.java
import com.wizzardo.tools.misc.Unchecked;
import com.wizzardo.tools.reflection.FieldReflection;
import com.wizzardo.tools.reflection.FieldReflectionFactory;
import com.wizzardo.tools.reflection.UnsafeTools;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.regex.Pattern;
import static com.wizzardo.epoll.Utils.readInt;
import static com.wizzardo.epoll.Utils.readShort;

    public void setTTL(long milliseconds) {
        ttl = milliseconds;
    }

    public long getTTL() {
        return ttl;
    }

    public void close() {
        synchronized (this) {
            if (running) {
                running = false;
                stopListening(scope);
                try {
                    join();
                } catch (InterruptedException ignored) {
                }
            }
        }
    }

    private void acceptConnections(byte[] buffer) throws IOException {
        int k;
        do {
            events.position(0);
            k = acceptConnections(scope, events.capacity() - 10);
            events.limit(k);
            events.get(buffer, 0, k);
//          eventCounter.addAndGet(k / 10);
            for (int j = 0; j < k; j += 10) {
                putConnection(createConnection(readInt(buffer, j), readInt(buffer, j + 4), readShort(buffer, j + 8)));