package upem.net.udp.selector;


import java.io.IOException;
import java.net.SocketAddress;
import java.net.StandardProtocolFamily;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.util.List;
import java.util.Set;

/**
 * Created by carayol on 20/02/15.
 */
public class RequesterLongSumNIOTemplate {

    private final DatagramChannel dc;
    private final Selector selector;
    private final SocketAddress serverAddress;
    private long currentSession;
    private final SelectionKey key;

    public RequesterLongSumNIOTemplate(SocketAddress serverAddress) throws IOException {
        selector=Selector.open();
        dc=DatagramChannel.open(StandardProtocolFamily.INET);
        dc.bind(null);
        dc.configureBlocking(false);
        key=dc.register(selector, SelectionKey.OP_READ|SelectionKey.OP_WRITE);
        currentSession=0;
        this.serverAddress=serverAddress;
    }

    public void close() throws IOException {
        selector.close();
        dc.close();
    }

    public Long query(List<Long> list,int timeoutInMilliSeconds) throws IOException {
        // TODO
        return 0l;
    }

 }
