public function open($address) { $address = "tcp://{$address}"; $stream = stream_socket_server($address, $errno, $errstr); if ($stream === false) { throw new Exception("Error ({$errno}): {$errstr}"); } parent::open($stream); $this->setBlocking(false); $this->on("rawdata", "onRawData"); }
public function __construct($address = null) { parent::__construct(); // $this->setBlocking(false); if (is_null($address)) { return; } if (is_resource($address)) { $this->open($address); } else { // TODO: open socket by address } }
public function __construct(\Phasty\Stream\Stream $stream) { $this->stream = $stream; $stream->on("data", [$this, "onData"]); }
public function __construct($resource = null) { parent::__construct($resource); $this->on("rawdata", [$this, "onRawData"]); }