here is where we handle the input and the
types of input -> read and writes from the stream

@return bool
977642
public function execute()
    {
        // loop through the open client connections
        foreach ($this->client as $key => $client) {
            // if the client connection doesn exist in the current read iteration
            if (!in_array($client['sock'], $this->read)) {
                // Close the socket
                $this->close($client['sock']);
                // flag for garbage collection
                unset($this->client[$key]);
            }

            // get the input from the client
            $input = socket_read($client['sock'], 1024);


            // Zero length string meaning disconnected
            if ($input == null) {
                unset($this->client[$key]);
            }
            $n = trim($input);

            switch (true) {
                // kill switch for telnet
                case $n === 'exit':
                    $this->close($client['sock']);
                    break;

                default:
                    // here is where it get interesting we will need a Handler who responds
                    socket_write($client['sock'], $this->getResponse($input));
                    break;
            }
        }
    }
1324159
public function isWritable()
    {
        if (is_resource($this->stream) === true) {
            $metadata = $this->getMetadata();
            return Validator::isWritable($metadata);
        }
        return false;
    }
1099162
public function stream_flush()
    {
        if ( ! $this->needsFlush) {
            return true;
        }

        $this->needsFlush = false;
        $this->bytesWritten = 0;

        // Calling putStream() will rewind our handle. flush() shouldn't change
        // the position of the file.
        $pos = ftell($this->handle);

        $args = [$this->getTarget(), $this->handle];
        $success = $this->invoke($this->getFilesystem(), 'putStream', $args, 'fflush');

        if (is_resource($this->handle)) {
            fseek($this->handle, $pos);
        }

        return $success;
    }
324932
private function read()
    {
        $this->lock();

        $data = '';

        rewind($this->handle);

        $data = trim(stream_get_contents($this->handle));

        if ($data !== '') {
            $this->data = unserialize($data);
            $data = null;
        }

        flock($this->handle, LOCK_UN);

        $this->iterator = new \ArrayIterator($this->data);
    }
1046072
public function eof() : bool
    {
        if ($this->closed) {
            throw new IoException('The stream is closed.');
        }

        try {
            return ErrorCatcher::run(function() {
                return feof($this->handle);
            });
        } catch (\ErrorException $e) {
            throw new IoException($e->getMessage(), 0, $e);
        }
    }
727669
protected function readLine()
    {
        if (! $this->valid()) {
            throw new Error('End of stream reached, no data to read');
        }
        $this->currentData = fgetcsv($this->fp, null, $this->delimiter, $this->enclosure);
        // Check if EOF is reached
        if (false === $this->currentData) {
            return false;
        } elseif (array(null) == $this->currentData) {
            /*
             * An empty line in the csv file
             * is returned as an array containing a NULL value.
             */
            if (! $this->ignoreEmptyLines) {
                throw new Error('Empty line found in file');
            }
            return $this->readLine();
        }
        $this->curLine++;

        if ($this->inputEncoding != $this->outputEncoding) {
            $inEnc = $this->inputEncoding;
            $outEnc = $this->outputEncoding;
            array_walk($this->currentData, function (&$str) use ($inEnc, $outEnc) {
                $str = mb_convert_encoding($str, $outEnc, $inEnc);
            });
        }

        return $this->currentData;
    }
230218
public function processRequest()
    {
        if(!$this->canProcessRequest())
        {
            return false;
        }
        if(count($_FILES) > 0)
        {
            $this->readFromHttpData();
        }
        elseif(($this->sTempFile))
        {
            $this->readFromTempFile();
        }
        return true;
    }
511457
private function initWritableStream()
    {
        $context = stream_context_get_options($this->context);

        $this->stream = new WritableStream(
            $context[$this->protocol]['collectionWrapper'],
            $context[$this->protocol]['filename'],
            $context[$this->protocol]['options']
        );

        return true;
    }
1368290
protected function readInput()
    {
        if (!$this->parser) {
            if ('-' !== $this->inputPath) {
                $this->stdin = fopen($this->inputPath, 'r');
            }

            if ('mimedir' === $this->inputFormat) {
                $this->parser = new Parser\MimeDir($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
            } else {
                $this->parser = new Parser\Json($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
            }
        }

        return $this->parser->parse();
    }
1201036
public function tell(): int
    {
        if (null === $this->handle) {
            throw new \LogicException('Can not read from closed input stream.');
        }

        $position = @ftell($this->handle);
        if (false === $position) {
            throw new StreamException(
                    'Can not read current position in file: '
                    . lastErrorMessage('unknown error')
            );
        }

        return $position;
    }
127238
public function stream()
	{
		$fp = fopen("php://memory", 'r+');
		fwrite($fp, $this->_string);
		rewind($fp);
		return $fp;
	}
44308
public function read()
	{
		if( $fcont = @file( $this->uri ) )
		{
			$this->data = array();
			foreach( $fcont as $line )
				$this->data[] = explode( "|", trim( $line ) );
			$this->open	= true;
			return true;
		}
		return false;
	}
2438
protected function doInput()
    {
        /* @var $result IReadResult */
        $this->resetInput();
        $this->inputAttemptsUsed++;
        $result = $this->playPrePromptMessages();
        if (!$this->acceptPrePromptInputAsInput) {
            $result = $this->playPromptMessages();
            if ($result !== null && !$result->isTimeout()) {
                $this->acceptInput($result->getDigits());
            }
        } elseif ($result !== null && !$result->isTimeout()) {
            $this->acceptInput($result->getDigits());
        } else {
            $result = $this->playPromptMessages();
            if ($result !== null) {
                $this->acceptInput($result->getDigits());
            }
        }
        if ($this->inputLengthIsAtLeast($this->maxInput) // max = 1
            || $this->wasCancelled()
            || ($this->isComplete() && !$this->hasInput()) // user pressed eoi
        ) {
            return;
        }
        $len = strlen($this->input);
        $start = time();
        for ($i = $len; $i < $this->maxInput; $i++) {
            if ($this->totalTimeForInput != -1) {
                $totalElapsedTime = (time() - $start) * 1000;
                if ($totalElapsedTime >= $this->totalTimeForInput) {
                    $this->logDebug("Expired total available time for input");
                    break;
                }
            }
            $this->logDebug($this->name . ": Reading Digit #: " . ($i + 1));
            $result = $this->callClientMethods(array(
                    array('waitDigit' => array($this->timeBetweenDigits))
            ));
            if ($result->isTimeout()) {
                $this->logDebug("Expired available time per digit");
                break;
            }
            $input = $result->getDigits();
            $this->acceptInput($input);
            if ($this->inputIsEnd($input) || $this->wasCancelled()) {
                break;
            }
        }
    }
73393
public function onRead()
    {
        if (($head = $this->lookExact(static::HEADER_LENGTH)) === false) {
            return;
        }

        list($magic, $typeInt, $size) = unpack(static::HEADER_READ_FORMAT, $head);

        if ($this->getInputLength() < static::HEADER_LENGTH + $size) {
            return;
        }

        $this->drain(static::HEADER_LENGTH);
        $pct = $this->read($size);

        if ($magic === static::MAGIC_RESPONSE) {
            $this->responseType = static::$responseCommandListFlipped[$typeInt];
            $this->response = explode(static::ARGS_DELIMITER, $pct);
            $this->onResponse->executeOne($this);
            $this->responseType = null;
            $this->responseCommand = null;
            $this->responseType = null;
            $this->checkFree();
            return;
        } else {
            $type = static::$requestCommandListFlipped[$typeInt];
            // @TODO
        }
    }
680368
public function isWritable()
    {
        if ($this->stream) {
            $meta = $this->getMetadata();
            $writableModes = ['r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+'];
            foreach ($writableModes as $mode) {
                if (strpos($meta['mode'], $mode) === 0) {
                    return true;
                }
            }
        }
        return false;
    }
606603
public function read()
    {
        $data = @fread($this->stream, 30000);

        if($data === false) return;
        $this->buffer .= $data;

        if(!is_null($this->status)) return;
        if(strlen($this->buffer) < 4) return;
        $end = strpos($this->buffer, "\r\n\r\n", 4);
        if($end === false) return;

        list($request, $headers) = $this->parse_header(substr($this->buffer, 0, $end));
        list($version, $status, $phrase) = explode(' ', $request, 3);
        $this->status = $status;
        $this->response_length = isset($headers['content-length'])? (int)$headers['content-length'][0] : 0;
    }
347703
public function onRead()
    {
        $seq = ["\xff\xf4\xff\xfd\x06", "\xff\xec", "\x03", "\x04"];
        $finish = false;
        foreach ($seq as $s) {
            if ($this->search($s) !== false) {
                $finish = true;
            }
        }
        while (($line = $this->readline()) !== null) {
            $line = rtrim($line, "\r\n");
            $e = explode(' ', $line, 2);
            $cmd = trim(strtolower($e[0]));
            $arg = isset($e[1]) ? $e[1] : '';

            if ($cmd === 'quit' || $cmd === 'exit') {
                $this->disconnect();
            } elseif (!$this->auth) {
                $this->checkPassword($line);
            } else {
                $this->processCommand($cmd, $arg);
            }
        }

        if ($finish) {
            $this->finish();
        }
    }