socket_sendto
socket_sendto
Sends a message to a socket, whether it is connected or not
**socket_sendto** Socket $socket string $data int $length int $flags string $address $port
The function sends
bytes from
through the socket to the
at the address .
socket_sendto``length``data``socket``port``address
socket
A instance created using .
Socket``socket_create
data
The sent data will be taken from buffer .
data
length
bytes from will be
sent.
length``data
flags
The value of can be any combination of
the following flags, joined with the binary OR ()
operator.
`flags``|`
addressIP address of the remote host.
port
is the remote port number at which the data
will be sent.
port
returns the number of bytes sent to the
remote host, or false if an error occurred.
socket_sendto
Voorbeeld: Example
<?php
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$msg = "Ping !";
$len = strlen($msg);
socket_sendto($sock, $msg, $len, 0, '127.0.0.1', 1223);
socket_close($sock);
?>
socket_send