1--TEST--
2swoole_socket_coro: cancel
3--SKIPIF--
4<?php require __DIR__ . '/../include/skipif.inc'; ?>
5--FILE--
6<?php
7require __DIR__ . '/../include/bootstrap.php';
8
9$socket = new Swoole\Coroutine\Socket(AF_INET, SOCK_DGRAM, 0);
10$socket->bind('127.0.0.1', 9601);
11//Server
12go(function () use ($socket) {
13    while (true) {
14        $peer = null;
15        $data = $socket->recvfrom($peer);
16        Assert::assert(empty($data));
17        Assert::assert($socket->errCode == SOCKET_ECANCELED);
18        break;
19    }
20    echo "DONE\n";
21});
22
23//Client
24go(function () use ($socket) {
25    co::sleep(0.1);
26    $socket->cancel();
27});
28swoole_event_wait();
29?>
30--EXPECT--
31DONE
32