<?php
/*
	printme.php - client for stream manager
	Copyright 2006 by Stephen D. Teter
	All rights reserved.
*/

// error_reporting (E_ALL);

$addr = '127.0.0.1';
$port = 1283;

function printMe($this) {
    global $port, $addr;
    $out = "Unknown error";
    $socket = socket_create (AF_INET, SOCK_STREAM, SOL_TCP);
    if ($socket < 0) {
        $out = "socket_create() failed: reason: " . socket_strerror ($socket) . "\n";
    } else {
        $result = socket_connect ($socket, $addr, $port);
        if ($result < 0) {
            $out = "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
        } else {
//            echo "Writing [$socket] with [$ebuf]\n";
            socket_write ($socket, $cmd);
            $out = socket_read ($socket, 100000);
            socket_close ($socket);
        }
    }
    return( $out );
}

?>
