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