Code example for SelectionKey

Methods: channel

0
 
    protected Client(SelectionKey key, InputThread server){
        this.key=key;
        this.server=server;
 
        sock=(SocketChannel)key.channel();
    } 
 
    public void close(){ 
        try { 
            server.close(key);
        } catch (IOException ex) {}
    } 
 
    public final void write(String packet) throws IOException{
        packet+=(char)0x00;
        sock.write(ByteBuffer.wrap(packet.getBytes()));
    } 
 
    public final void send(String packet){
        server._out.send(this, packet);