Created
September 13, 2017 13:47
-
-
Save benhubert/5ea92104d0422e66fb30623e78da5267 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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