Skip to content

Instantly share code, notes, and snippets.

@codeanticode
Created August 12, 2016 00:18
Show Gist options
  • Save codeanticode/3953b7a97bca67acc7aa64c51f2331f0 to your computer and use it in GitHub Desktop.
Save codeanticode/3953b7a97bca67acc7aa64c51f2331f0 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.net.*;
void setup() {
thread("keepAlive");
}
void draw() {
}
void keepAlive() {
String UDP_IP = "10.5.5.9";
int UDP_PORT = 8554;
int KEEP_ALIVE_PERIOD = 2500;
while (true) {
println("sending message...");
try {
DatagramSocket clientSocket = new DatagramSocket();
String sendMessage = "_GPHD_:0:0:2:0.000000\n";
byte[] sendData = sendMessage.getBytes();
InetAddress IPAddress = InetAddress.getByName(UDP_IP);
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, UDP_PORT);
clientSocket.send(sendPacket);
clientSocket.close();
println("message sent!");
} catch (Exception ex) {
println("ERROR!");
}
delay(KEEP_ALIVE_PERIOD);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment