<?php
function ugo_send_to_ip($ip, $port, $data) {

  $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

  if ($socket === false) {
    //echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
	$ret["success"]="false";
  }

  $result = socket_connect($socket, $ip, $port);
  if ($result === false) {
    //echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
    $ret["success"]="false";
  }
  
  $len = strlen($data);
  
  $r = socket_write($socket, $data, $len);
  
/*  while ($out = socket_read($socket, 2048)) {
    echo $out;
  }
*/
  socket_close($socket);  
  
  return $r == $len;
}
?>