protected function sendToClient($line)
    {
        $bytes = 0;
        $len   = strlen($line);
        if ($len) {
            while(true) {
                $sent = socket_write($this->client, $line, $len);
                if (false === $sent) {
                    throw new Exceptions\HttpStatusError(
                        "Internal server error.",
                        500
                    );
                }

                $bytes += $sent;
                if ($sent < $len) {
                    $line = substr($line, $sent);
                    $len -= $sent;
                } else {
                    break;
                }
            }
        }

        return $bytes;
    }