Reading and Writing
- public function read() — Read from the channel. A channel defines the format of data that is read from it, so this method may return strings, objects, or anything else.
- public function write($bytes) — Write to the channel. A channel defines what data format it accepts, so this method may take strings, objects, or anything else.
Waiting for Activity
- public static function waitForAny($channels, $options) — Wait for any activity on a list of channels. Convenience wrapper around @{method:waitForActivity}.
- public static function waitForActivity($reads, $writes, $options) — Wait (using select()) for channels to become ready for reads or writes. This method blocks until some channel is ready to be updated.
Responding to Activity
- public function update() — Updates the channel, filling input buffers and flushing output buffers. Returns false if the channel has closed.
Channel Implementation
- public function setName($name) — Set a channel name. This is primarily intended to allow you to debug channel code more easily, by naming channels something meaningful.
- public function getName() — Get the channel name, as set by @{method:setName}.
- public function isOpen()
- public function closeWriteChannel()
- public function isOpenForReading()
- public function isOpenForWriting()
- protected function readBytes($length)
- protected function writeBytes($bytes)
- protected function getReadSockets()
- protected function getWriteSockets()
- public function setReadBufferSize($size) — Set the maximum size of the channel's read buffer. Reads will artificially block once the buffer reaches this size until the in-process buffer is consumed.
- public function isReadBufferEmpty() — Test state of the read buffer.
- public function isWriteBufferEmpty() — Test state of the write buffer.
- public function getWriteBufferSize() — Get the number of bytes we're currently waiting to write.
- public function flush() — Wait for any buffered writes to complete. This is a blocking call. When the call returns, the write buffer will be empty.
Construction
- public function __construct($read_socket, $write_socket) — Construct a socket channel from a socket or a socket pair.
- public static function newChannelPair() — Creates a pair of socket channels that are connected to each other. This is mostly useful for writing unit tests of, e.g., protocol channels.
Other Methods
- public function __destruct()
- private function closeReadSocket()
- private function closeWriteSocket()
- private function closeOneSocket($socket)
- private function closeSockets()