(PHP 4 >= 4.1.0, PHP 5)

socket_sendto -- Sends a message to a socket, whether it is connected or not


int socket_sendto ( resource socket, string buf, int len, int flags, string addr [, int port])


This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk.

The function socket_sendto() sends len bytes from buf through the socket socket to the port at the address addr

The value of flags can be one of the following:

Table 1. possible values for flags

0x1 Process OOB (out-of-band) data.
0x2 Peek at incoming message.
0x4 Bypass routing, use direct interface.
0x8 Data completes record.
0x100 Data completes transaction.

Example 1. socket_sendto() Example

= socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if (
socket_bind($sh, '', 4242)) {
"Socket bound correctly";
$buf = 'Test Message';
$len = strlen($buf);
    if (
socket_sendto($sh, $buf, $len, 0x100, '', 4242) !== false) {
"Message sent correctly";

See also socket_send() and socket_sendmsg().

Sites of interest: Web Hosting : Reseller Hosting : Website Hosting : HTML Editor : Web Design Templates : Free Web Hosting : ASP code examples : PHP & MySQL Code Examples
  Copyright 2004 Evrsoft Developer Network. Privacy policy - Link to Us

Contact Evrsoft