//creo la conexio socket
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); //protocolo UDP
//$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //protocolo TCP
//obtengo valor en bytes
$len = strlen($msg->toString(1));
//envio informacion a socket
$sendMsg = socket_send($sock, $msg->toString(1), $len, MSG_DONTROUTE);
//cierro conexion iniciada
socket_close($sock);