PHP stream_socket_sendto() Function
The PHP stream_socket_sendto() function is used to send the specified data through the socket.
Syntax
stream_socket_sendto(socket, data, flags, address)
Parameters
socket |
Required. Specify the socket to send data to. |
data |
Required. Specify the data to be sent. |
flags |
Optional. The value of flags can be any combination of the following:
|
address |
Optional. The address specified when the socket stream was created will be used unless an alternate address is specified in address. If specified, it must be in dotted quad (or [ipv6]) format. |
Return Value
Returns a result code, as an integer.
Example: stream_socket_sendto() example
The example below shows the usage of stream_socket_sendto() function.
<?php //opening a socket to port 1234 on localhost $socket = stream_socket_client('tcp://127.0.0.1:1234'); //sending ordinary data via ordinary channels fwrite($socket, "Normal data transmit."); //sending more data out of band stream_socket_sendto($socket, "Out of Band data.", STREAM_OOB); //closing the socket fclose($socket); ?>
❮ PHP Streams Reference