Esempio n. 1
0
 public function read($size)
 {
     (yield waitForRead($this->socket));
     (yield retval(fread($this->socket, $size)));
 }
Esempio n. 2
0
function handleClient($socket)
{
    echo "handclient:waitForRead\n";
    (yield waitForRead($socket));
    echo "handclient:Read\n";
    $data = fread($socket, 8192);
    $msg = "Received following request:\n\n{$data}";
    $msgLength = strlen($msg);
    $response = <<<RES
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: {$msgLength}
Connection: close

{$msg}
RES;
    echo "handclient:waitForWrite\n";
    (yield waitForWrite($socket));
    echo "handclient:Write\n";
    fwrite($socket, $response);
    fclose($socket);
}
Esempio n. 3
0
 public function read($size)
 {
     echo "cosocket read\n";
     (yield waitForRead($this->socket));
     (yield retval(fread($this->socket, $size)));
 }