@Override
public void run() {
try {
InetSocketAddress connectAddr = new InetSocketAddress("127.0.0.1", 5140);
ByteChannel out;
if ("tcp".equals(transport)) {
SocketChannel channel = SocketChannel.open();
channel.connect(connectAddr);
out = channel;
}
else {
DatagramChannel channel = DatagramChannel.open();
channel.connect(connectAddr);
out = channel;
}
ByteBuffer buff = ByteBuffer.wrap(
("<34>Oct 11 22:14:15 mymachine su: 'su root' failed for lonvick on /dev/pts/8\n").getBytes()
);
for (int i = 0; i < runs; i++) {
out.write(buff);
buff.flip();
if ("udp".equals(transport)) {
Thread.sleep(5);
}
}
out.close();
}
catch (Exception e) {
throw new IllegalStateException(e);
}
}