pid_sendto()


int pid_sendto ( int $pid, int/string $buf [ , int $len, int $flags, string $addr, int $port ] )

Description

pid_sendto() transmits $len bytes of data from $buf through UDP $pid to the $port at the address $addr.

※ available F/W version : all

Parameters

Return values

Returns the number of bytes sent, PHP error on error

Examples

<?php
$buf = "Hello PHPoC!";
$peer_addr = "10.3.0.10";
$peer_port = 1470;

$pid = pid_open("/mmap/udp0");
pid_ioctl($pid, "set dstaddr $peer_addr");
pid_ioctl($pid, "set dstport $peer_port");

$wlen = pid_sendto($pid, $buf);
echo "udp sent: $wlen bytes\r\n";
?>
<?php
$buf = "Hello PHPoC!";
$peer_addr = "10.3.0.10";
$peer_port = 1470;

$pid = pid_open("/mmap/udp0");
pid_bind($pid, "", 1470);

$wlen = pid_sendto($pid, $buf, strlen($buf), 0, $peer_addr, $peer_port);
echo "udp sent: $wlen bytes\r\n";
?>

See also

pid_open() / pid_ioctl() / pid_bind() / pid_recvfrom()

Remarks

None