amphp / socket

Non-blocking socket and TLS functionality for PHP based on Amp.

Home Page:https://amphp.org/socket

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: on connect

opened this issue · comments

<?php
require_once __DIR__ . "/../vendor/autoload.php";

\Amp\Loop::run(function()
{
    \Amp\Socket\connect("tcp://127.0.0.1:1")->onResolve(function (Throwable $error = null, \Amp\Socket\Socket $socket = null) {
//        var_dump($error);

        assert($error !== null); //FAIL
    });

    \Amp\Socket\connect("tcp://8.8.8.8:53")->onResolve(function (Throwable $error = null, \Amp\Socket\Socket $socket = null) {
//        var_dump($error);

        assert($error === null);
    });

    \Amp\Socket\connect("tcp://8.8.8.8:1234")->onResolve(function (Throwable $error = null, \Amp\Socket\Socket $socket = null) {
//        var_dump($error);

        assert($error !== null);
    });

    \Amp\Socket\connect("unix:///tmp/invalid")->onResolve(function (Throwable $error = null, \Amp\Socket\Socket $socket = null) {
//        var_dump($error);

        assert($error !== null);
    });

    \Amp\Socket\connect("unix:///tmp/11001")->onResolve(function (Throwable $error = null, \Amp\Socket\Socket $socket = null) {
//        var_dump($error);

        assert($error === null);
    });
});