Skip to content

Instantly share code, notes, and snippets.

@benhubert
Created September 13, 2017 13:47
Show Gist options
  • Save benhubert/5ea92104d0422e66fb30623e78da5267 to your computer and use it in GitHub Desktop.
Save benhubert/5ea92104d0422e66fb30623e78da5267 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.net.*;
/**
* Simple UDP server that listens for packets on port 8125 and
* prints them. Intended for testing a StatsD client.
*/
public class StatsdLogger
{
public static void main(String args[]) throws Exception {
DatagramSocket serverSocket = new DatagramSocket(8125);
while(true) {
DatagramPacket receivePacket = new DatagramPacket(new byte[1024], 1024);
serverSocket.receive(receivePacket);
String sentence = new String(receivePacket.getData());
System.out.println("RECEIVED: " + sentence);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment