Rogan said:
And no, I'm not really on the bandwagon that C is faster than Java, but
for a specialised task such as this, where you have extreme volumes of
data, you probably DO want to do this in the fastest language available
to you.
Here's a counter-view:
I'm not really on the bandwagon that java is better than C, but for a task such
as this, where you have uncontrolled, and potentially hostile, data sent to you
from anywhere on the network (or even the Net if your firewall's broken or
compromised), you probably don't want to use an unsafe language such as C.
;-)
In reality, of course, it mostly depends on what the OP wants to do, and what
constraints (performance and others) have to be satisfied.
But I know of no reason why a syslog listener couldn't be written in Java[*],
whether that is the optimal approach is another question.
-- chris
[*] A grossly over-simplified implementation:
import java.net.*;
import java.io.*;
public class Syslog
{
private static final int PORT = 514;
private static final int BUFFER_SIZE = 10000;
public static void
main(String[] args)
throws IOException
{
new Syslog().run();
}
private void
run()
throws IOException
{
DatagramSocket socket = new DatagramSocket(PORT);
DatagramPacket packet = new DatagramPacket(
new byte[BUFFER_SIZE],
BUFFER_SIZE);
for (;
{
packet.setLength(BUFFER_SIZE);
socket.receive(packet);
System.out.printf("Got %d bytes from %s%n",
packet.getLength(),
packet.getSocketAddress());
System.out.write(packet.getData());
System.out.println("==========");
}
}
}