Skip to content

Instantly share code, notes, and snippets.

Created April 13, 2016 23:46
What would you like to do?
send basic UDP messages from PHP
$serverIP = '';
$serverPort = 5000;
if ($_REQUEST['cmd']) {
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if (!$socket) {
error_log("Could not open socket");
} else {
socket_sendto($socket, $_REQUEST['cmd'], strlen($_REQUEST['cmd']), 0, $serverIP, $serverPort);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment