Skip to content

Instantly share code, notes, and snippets.

@chriswhitcombe
Created January 4, 2012 19:53
Show Gist options
  • Save chriswhitcombe/1561725 to your computer and use it in GitHub Desktop.
Save chriswhitcombe/1561725 to your computer and use it in GitHub Desktop.
send a message to graphite over UDP
// get a datagram socket
DatagramSocket udpSocket = new DatagramSocket();
// send request
byte[] buf = msg.getBytes();
InetAddress address = InetAddress.getByName(graphiteHost);
System.out.println(address);
DatagramPacket packet = new DatagramPacket(buf, buf.length, address, graphitePort);
udpSocket.send(packet);
udpSocket.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment