{
log.info(e);
}
}
}
public class Writer implements Reactor
{
private static final Log log = LogFactory.getLog(Writer.class);
private ByteBuffer output;
public Writer(ByteBuffer output)
{
this.output=output;
}
public void execute(SelectionKey key)
{
SocketChannel sc = (SocketChannel) key.channel();
try
{
while(sc.isConnected() && output.hasRemaining())
{
int len=sc.write(output);
{
throw new EOFException();
}
if(len==0)
{
key.interestOps(SelectionKey.OP_WRITE);
key.selector().wakeup();
break;
}
}
if(!output.hasRemaining())
{
output.clear();
key.cancel();
sc.close();
}
}
catch(IOException e)
{
log.info(e);
}
}
}