Beispiel #1
0
 public function write($string)
 {
     (yield waitForWrite($this->socket));
     fwrite($this->socket, $string);
 }
Beispiel #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);
}
Beispiel #3
0
 public function write($string)
 {
     echo "cosocket write\n";
     (yield waitForWrite($this->socket));
     fwrite($this->socket, $string);
 }