(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)
socket_sendto — Invia un messaggio ad un socket, a prescindere che sia connesso o meno
$socket
,$buf
,$len
,$flags
,$addr
,$port
= ?Questa funzione è SPERIMENTALE. Ovvero, il comportamento di questa funzione, il nome di questa funzione, in definitiva tutto ciò che è documentato qui può cambiare nei futuri rilasci del PHP senza preavviso. Siete avvisati, l'uso di questa funzione è a vostro rischio.
La funzione socket_sendto() invia
len
bytes dal buffer buf
attraverso il socket socket
alla porta
port
dell'indirizzo addr
Il valore ammessi per flags
può essere uno dei
seguenti:
0x1 |
Elabora dati OOB (fuori banda). |
0x2 |
Preleva il messaggio in arrivo. |
0x4 |
Ignora il routing, usa l'interfaccia diretta. |
0x8 |
I dati completano il record. |
0x100 |
I dati completano al transazione. |
Example #1 Esempio di socket_sendto()
<?php
$sh = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (socket_bind($sh, '127.0.0.1', 4242)) {
echo "Socket agganciato correttamente";
}
$buf = 'Test Message';
$len = strlen($buf);
if (socket_sendto($sh, $buf, $len, 0x100, '192.168.0.2', 4242) !== false) {
echo "Messaggio inviato correttamente";
}
socket_close($sh);
?>
Vedere anche socket_send() e socket_sendmsg().