tcp_write()


Trasmitting data to the designated TCP session(ID)

Description

int tcp_write(int $tcp_id, int/string $wbuf [, int $wlen = MAX_STRING_LEN])

Parameters

Return Value

On success returns the transmitted bytes, otherwise 0

Example

<?php
include "/lib/sn_tcp_ac.php";
$port = 1470;
tcp_server(0, $port);           // listenning the port for a TCP connection (TCP ID: 0)
$rwbuf = "";
while(1)
{
  $rwlen = tcp_read(0, $rwbuf); // Reading TCP receiving buffer
  if($rwlen > 0)
    tcp_write(0, $rwbuf);       // transmitting the received data
}
?>

See also