Giter Site home page Giter Site logo

Fail to run the example code about icicle HOT 6 CLOSED

icicleio avatar icicleio commented on August 22, 2024
Fail to run the example code

from icicle.

Comments (6)

trowski avatar trowski commented on August 22, 2024

I've fallen behind on updating the readme on this repo since I'm preparing some formal docs that will be posted at icicle.io/docs. That example is out of date (plus you need to require the DNS package as well). Try requiring icicleio/dns and run the examples found in that package.

from icicle.

rylanathk avatar rylanathk commented on August 22, 2024

I have tried http://icicleio.github.io/docs/getting-started/ this example but still got the error Class 'Icicle\Http\Server\Server' not found

from icicle.

trowski avatar trowski commented on August 22, 2024

That example requires the icicleio/http package and is also out of date. Look at the examples found in that package. I'll try updating all the examples today or tomorrow. Clearly there needs to be some more basic examples on the getting started page that only rely on the base package.

from icicle.

nexor avatar nexor commented on August 22, 2024

Hello! I found strange bug in DNS package. The following code hangs up into endless loop and consumes 100% CPU:

#!/usr/bin/php
<?php

use Icicle\Coroutine;
use Icicle\Loop;
use Icicle\Http\Client\Client;

require __DIR__.'/vendor/autoload.php';

$generator = function() {
    echo "Connecting to server\n";
    $httpClient = new Client();

    $socket = yield from \Icicle\Dns\connect('www.google.com', 80);
    //$socket = yield from \Icicle\Dns\connect('77.37.250.212', 80);

    echo "Socket OK\n";
    echo $socket ? get_class($socket) : "NULL";
    echo "\n";
};

$coroutine = Coroutine\create($generator);

echo "RUN LOOP\n";
Loop\run();

composer.json:

{
    "minimum-stability": "dev",
    "require": {
        "icicleio/icicle": "~2.0",
        "icicleio/http": "*",
        "icicleio/dns": "*"
    }
}

console output:

$ ./run.php 
Connecting to server
RUN LOOP

But if I use commented line $socket = yield from \Icicle\Dns\connect('77.37.250.212', 80); - all is OK:

$ ./run.php 
Connecting to server
RUN LOOP
Socket OK
Icicle\Socket\NetworkSocket

Some additional info:

$ php -v
PHP 7.0.2-2+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.4.0RC3, Copyright (c) 2002-2015, by Derick Rethans
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"

Is it known problem?

from icicle.

trowski avatar trowski commented on August 22, 2024

@nexor This behavior was due to #17 that affects PHP 7.0.2. Your example code would hang in an infinite loop because the DNS lookup uses some code from the stream package that was affected by the bug. Using the IP address bypassed the affected code used by the DNS lookup. I've updated the stream package to avoid the bug, so run composer update and try again, it should work as expected now.

@yobichi The documentation at icicle.io/docs has been updated with more examples to come. Please look there for examples and documentation. If you find any mistakes, please file an issue or PR on the repo at https://github.com/icicleio/docs.

from icicle.

nexor avatar nexor commented on August 22, 2024

Thanks! Now all works fine 👍

from icicle.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.