コード例 #1
0
 public function write($string)
 {
     (yield waitForWrite($this->socket));
     fwrite($this->socket, $string);
 }
コード例 #2
0
ファイル: server-non-block.php プロジェクト: chendeng/php-lib
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);
}
コード例 #3
0
ファイル: CoSocket.php プロジェクト: xiaobudongzhang/lib
 public function write($string)
 {
     echo "cosocket write\n";
     (yield waitForWrite($this->socket));
     fwrite($this->socket, $string);
 }