Name Date Size #Lines LOC

..31-Aug-2021-

.github/workflows/H22-Aug-2021-

examples/H17-Feb-2020-

tests/H17-Feb-2020-

.gitignoreH A D06-Dec-2019512 4843

LICENSEH A D06-Dec-20193.1 KiB6955

Makefile.fragH A D06-Dec-2019113 64

README.mdH A D06-Dec-201941.5 KiB2,9591,550

TODO.mdH A D06-Dec-20191.3 KiB3525

config.m4H A D06-Dec-20193 KiB9782

config.w32H A D06-Dec-2019619 2518

package.xmlH A D06-Dec-20196.1 KiB147146

php_uv.cH A D12-Nov-2021166.1 KiB6,5024,785

php_uv.hH A D22-Aug-20214.7 KiB252214

phpuv_dtrace.dH A D06-Dec-201949 33

uv.cH A D17-Feb-202015.5 KiB198156

README.md

1# php-uv
2
3[![Build Status](https://secure.travis-ci.org/bwoebi/php-uv.png)](http://travis-ci.org/bwoebi/php-uv)
4
5Interface to libuv for php.
6
7# Install
8
9## \*nix
10
11````
12git clone https://github.com/bwoebi/php-uv.git
13cd php-uv
14phpize
15./configure
16make
17make install
18# add `extension=uv.so` to your php.ini
19````
20
21## Windows
22
23Windows builds for stable PHP versions are available [from PECL](https://pecl.php.net/package/uv).
24
25# Examples
26
27see examples and tests directory.
28
29````php
30<?php
31$tcp = uv_tcp_init();
32
33uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',8888));
34
35uv_listen($tcp,100, function($server){
36    $client = uv_tcp_init();
37    uv_accept($server, $client);
38    var_dump(uv_tcp_getsockname($server));
39
40    uv_read_start($client, function($socket, $nread, $buffer){
41        var_dump($buffer);
42        uv_close($socket);
43    });
44});
45
46$c = uv_tcp_init();
47uv_tcp_connect($c, uv_ip4_addr('0.0.0.0',8888), function($stream, $stat){
48    if ($stat == 0) {
49        uv_write($stream,"Hello",function($stream, $stat){
50            uv_close($stream);
51        });
52    }
53});
54
55uv_run();
56````
57
58# Original Author
59
60* Shuhei Tanuma
61
62# Current Maintainer
63
64* Bob Weinand
65
66# License
67
68PHP License
69
70
71# Documents
72
73### void uv_unref(resource $uv_t)
74
75##### *Description*
76
77decrement reference
78
79##### *Parameters*
80
81*resource $uv_t*: uv resource handle.
82
83##### *Return Value*
84
85*void *:
86
87##### *Example*
88
89````php
90<?php
91$tcp = uv_tcp_init();
92uv_unref($tcp);
93
94````
95
96
97
98### long uv_last_error([resource $uv_loop])
99
100##### *Description*
101
102get last error code.
103
104##### *Parameters*
105
106*resource $uv_loop*: uv loop handle
107
108##### *Return Value*
109
110*long $error_code*: error code
111
112##### *Example*
113
114````php
115<?php
116$err = uv_last_error();
117var_dump($err);
118````
119
120
121### string uv_err_name(long $error_code)
122
123##### *Description*
124
125get error code name.
126
127##### *Parameters*
128
129*long $error_code*: libuv error code
130
131##### *Return Value*
132
133*string $erorr_name*: error name
134
135##### *Example*
136
137````php
138<?php
139$err = uv_last_error();
140var_dump(uv_err_name($err));
141````
142
143
144### string uv_strerror(long $error_code)
145
146##### *Description*
147
148get error message.
149
150##### *Parameters*
151
152*long $error_code*: libuv error code
153
154##### *Return Value*
155
156*string $erorr_message*: error message
157
158##### *Example*
159
160````php
161<?php
162$err = uv_last_error();
163var_dump(uv_strerror($err));
164````
165
166
167
168### void uv_update_time(resource $uv_loop)
169
170
171### void uv_ref(resource $uv_handle)
172
173##### *Description*
174
175increment reference count
176
177##### *Parameters*
178
179*resource $uv_handle*: uv resource.
180
181##### *Return Value*
182
183*void*:
184
185##### *Example*
186
187````php
188<?php
189$tcp = uv_tcp_init();
190uv_ref($tcp);
191````
192
193##### *TODO*
194
195* support uv_loop resource
196
197
198
199### void uv_run([resource $uv_loop])
200
201##### *Description*
202
203run event loop
204
205##### *Parameters*
206
207*resource $uv_loopg*: uv_loop resource
208
209##### *Return Value*
210
211*void*:
212
213##### *Example*
214
215````php
216<?php
217$loop = uv_default_loop();
218$async = uv_async_init($loop, function($async, $status){
219    var_dump(1);
220    uv_close($async);
221});
222
223uv_async_send($async);
224
225uv_run();
226````
227
228
229
230### void uv_run_once([resource $uv_loop])
231
232
233### void uv_loop_delete(resource $uv_loop)
234
235##### *Description*
236
237delete specified loop resource.
238
239##### *Parameters*
240
241*resource $uv_loop*: uv_loop resource
242
243##### *Return Value*
244
245*void*:
246
247##### *Example*
248
249
250
251### long uv_now(resource $uv_loop)
252
253
254### void uv_tcp_bind(resource $uv_tcp, resource $uv_sockaddr)
255
256##### *Description*
257
258binds a name to a socket.
259
260##### *Parameters*
261
262*resource $uv_tcp*: uv_tcp resource
263
264*resource $uv_sockaddr*: uv sockaddr4 resource.
265
266##### *Return Value*
267
268*void*:
269
270##### *Example*
271
272````php
273<?php
274$tcp = uv_tcp_init();
275
276uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));
277
278uv_listen($tcp,100, function($server){
279    $client = uv_tcp_init();
280    uv_accept($server, $client);
281    var_dump(uv_tcp_getsockname($server));
282
283    uv_read_start($client, function($socket, $nread, $buffer) use ($server){
284        var_dump($buffer);
285        uv_close($socket);
286        uv_close($server);
287    });
288});
289````
290
291
292
293### void uv_tcp_bind6(resource $uv_tcp, resource $uv_sockaddr)
294
295##### *Description*
296
297binds a name to a socket.
298
299##### *Parameters*
300
301*resource $uv_tcp*: uv_tcp resource
302
303*resource $uv_sockaddr*: uv sockaddr6 resource.
304
305##### *Return Value*
306
307*void*:
308
309##### *Example*
310
311````php
312<?php
313$tcp = uv_tcp_init();
314uv_tcp_bind6($tcp, uv_ip6_addr('::1',9999));
315
316uv_listen($tcp,100, function($server){
317    $client = uv_tcp_init();
318    uv_accept($server, $client);
319    var_dump(uv_tcp_getsockname($server));
320
321    uv_read_start($client, function($socket, $nread, $buffer) use ($server){
322        var_dump($buffer);
323        uv_close($socket);
324        uv_close($server);
325    });
326});
327````
328
329
330
331### void uv_write(resource $handle, string $data, callable $callback)
332
333##### *Description*
334
335send buffer to speicified uv resource.
336
337##### *Parameters*
338
339*resource $handle*: uv resources (uv_tcp, uv_udp, uv_pipe ...etc.)
340*string $data*: buffer.
341*callable $callback*: callable variables. this callback expects (resource $handle, long $status)
342
343##### *Return Value*
344
345*void*:
346
347##### *Example*
348
349
350
351### void uv_write2(resource $handle, string $data, resource $send, callable $callback)
352
353
354### void uv_tcp_nodelay(resource $handle, bool $enable)
355
356##### *Description*
357
358set Nagel's flags for specified tcp resource.
359
360##### *Parameters*
361
362*resource $handle*: libuv tcp resource
363
364*bool $enable*: true means enabled. false means disabled.
365
366##### *Return Value*
367
368*void*:
369
370##### *Example*
371
372````php
373<?php
374$tcp = uv_tcp_init();
375uv_tcp_nodelay($tcp, true);
376````
377
378
379### void uv_accept(resource $server, resource $client)
380
381##### *Description*
382
383accepts a connection on a socket.
384
385##### *Parameters*
386
387*resource $uv*: uv_tcp or uv_pipe server resource
388
389*resource $uv*: uv_tcp or uv_pipe client resource.
390
391##### *Return Value*
392
393*void*:
394
395##### *Example*
396
397````php
398<?php
399$tcp = uv_tcp_init();
400
401uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));
402
403uv_listen($tcp,100, function($server){
404    $client = uv_tcp_init();
405    uv_accept($server, $client);
406    var_dump(uv_tcp_getsockname($server));
407
408    uv_read_start($client, function($socket, $nread, $buffer) use ($server){
409        var_dump($buffer);
410        uv_close($socket);
411        uv_close($server);
412    });
413});
414````
415
416
417
418### void uv_shutdown(resource $handle, callable $callback)
419
420##### *Description*
421
422shutdown uv handle.
423
424##### *Parameters*
425
426*resource $handle*: uv resources (uv_tcp, uv_udp, uv_pipe ...etc.)
427*callable $callback*: callable variables. this callback expects (resource $handle, long $status)
428
429##### *Return Value*
430
431*void*:
432
433##### *Example*
434
435
436
437### void uv_close(resource $handle, callable $callback)
438
439##### *Description*
440
441close uv handle.
442
443##### *Parameters*
444
445*resource $handle*: uv resources (uv_tcp, uv_udp, uv_pipe ...etc.)
446*callable $callback*: callable variables. this callback expects (resource $handle, long $status)
447
448##### *Return Value*
449
450*void*:
451
452##### *Example*
453
454
455
456### void uv_read_start(resource $handle, callable $callback)
457
458##### *Description*
459
460starts read callback for uv resources.
461
462##### *Parameters*
463
464*resource $handle*: uv resources (uv_tcp, uv_udp, uv_pipe ...etc.)
465
466*callable $callback*: callable variables. this callback parameter expects (resource $handle, long $nread, string buffer)
467
468##### *Return Value*
469
470*void*:
471
472##### *Example*
473
474##### *Note*
475
476* You have to handle erorrs correctly. otherwise this will leak.
477* if you want to use PHP's stream or socket resource. see uv_fs_poll_init and uv_fs_read.
478
479
480
481### void uv_read2_start(resource $handle, callable $callback)
482
483
484### void uv_read_stop(resource $handle)
485
486##### *Description*
487
488stop read callback
489
490##### *Parameters*
491
492*resource $uv*: uv resource handle which started uv_read.
493
494##### *Return Value*
495
496*void*:
497
498##### *Example*
499
500````php
501<?php
502$tcp = uv_tcp_init();
503
504uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));
505
506uv_listen($tcp,100, function($server){
507    $client = uv_tcp_init();
508    uv_accept($server, $client);
509    var_dump(uv_tcp_getsockname($server));
510
511    uv_read_start($client, function($socket, $nread, $buffer) use ($server){
512        uv_read_stop($socket);
513        var_dump($buffer);
514        uv_close($socket);
515        uv_close($server);
516    });
517});
518````
519
520
521
522### resource uv_ip4_addr(string $ipv4_addr, long $port)
523
524##### *Description*
525
526create a ipv4 sockaddr.
527
528##### *Parameters*
529
530*string $ipv4_addr*: ipv4 address
531
532*long $port*: port number.
533
534##### *Return Value*
535
536*resource $uv_sockaddr*: sockaddr resource
537
538##### *Example*
539
540````php
541<?php
542$sockaddr = uv_ip4_addr("127.0.0.1", 8080);
543````
544
545##### *Todo*
546
547* check passed ip address is valid.
548* check port number is valid
549
550
551
552### resource uv_ip6_addr(string $ipv6_addr, long $port)
553
554##### *Description*
555
556create a ipv6 sockaddr.
557
558##### *Parameters*
559
560*string $ipv6_addr*: ipv6 address
561
562*long $port*: port number.
563
564##### *Return Value*
565
566*resource $uv_sockaddr*: sockaddr resource
567
568##### *Example*
569
570````php
571<?php
572$sockaddr = uv_ip6_addr("::1", 8080);
573````
574
575##### *Todo*
576
577* check passed ip address is valid.
578* check port number is valid
579
580
581
582### void uv_listen(resource $handle, long $backlog, callable $callback)
583
584##### *Description*
585
586listens for a connection on a uv handle.
587
588##### *Parameters*
589
590*resource $handle*: uv resource handle (tcp, udp and pipe)
591
592*long $backlog*: backlog
593
594*callable $callback*: this callback parameter expects (resource $connection, long $status)
595
596##### *Return Value*
597
598*void *:
599
600##### *Example*
601
602````php
603<?php
604$tcp = uv_tcp_init();
605
606uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));
607
608uv_listen($tcp,100, function($server, $status){
609    $client = uv_tcp_init();
610    uv_accept($server, $client);
611    uv_read_start($client, function($socket, $nread, $buffer) use ($server){
612        var_dump($buffer);
613        uv_close($socket);
614        uv_close($server);
615    });
616});
617uv_run();
618
619````
620
621
622
623### void uv_tcp_connect(resource $handle, resource $ipv4_addr, callable $callback)
624
625##### *Description*
626
627connect to specified ip address and port.
628
629##### *Parameters*
630
631*resource $handle*: requires `uv_tcp_init()` resource.
632*resource $ipv4_addr*: requires uv_sockaddr resource.
633*callable $callback*: callable variables.
634
635##### *Return Value*
636
637*void*:
638
639##### *Example*
640
641````php
642<?php
643$tcp = uv_tcp_init();
644uv_tcp_connect($tcp, uv_ip4_addr("127.0.0.1",8080), function($tcp_handle, $status){
645	uv_close($tcp_handle);
646});
647
648uv_run();
649````
650
651
652### void uv_tcp_connect6(resource $handle, resource $ipv6_addr, callable $callback)
653
654##### *Description*
655
656connect to specified ip address and port.
657
658##### *Parameters*
659
660*resource $handle*: requires `uv_tcp_init()` resource.
661*resource $ipv4_addr*: requires uv_sockaddr resource.
662*callable $callback*: callable variables.
663
664##### *Return Value*
665
666*void*:
667
668##### *Example*
669
670````php
671<?php
672$tcp = uv_tcp_init();
673uv_tcp_connect($tcp, uv_ip6_addr("::1",8080), function($tcp_handle, $status){
674	uv_close($tcp_handle);
675});
676
677uv_run();
678````
679
680
681### resource uv_timer_init([resource $loop])
682
683##### *Description*
684
685initialize timer handle.
686
687##### *Parameters*
688
689*resource $loop*: uv_loop resource.
690
691##### *Return Value*
692
693*resource $timer*: initialized timer resource.
694
695##### *Example*
696
697````php
698<?php
699$timer = uv_timer_init();
700````
701
702
703### void uv_timer_start(resource $timer, long $timeout, long $repeat, callable $callback)
704
705##### *Description*
706
707initialize timer handle.
708
709##### *Parameters*
710
711*resource $loop*: uv_loop resource.
712
713*long $timeout*: periodical event starts when after this timeout. 1000 is 1 sec.
714
715*long $repeat*: repeat interval. 1000 is 1 sec.
716
717##### *Return Value*
718
719*void:
720
721##### *Example*
722
723````php
724<?php
725$timer = uv_timer_init();
726$after_1_second = 1000;
727$period_is_1_second = 1000;
728uv_timer_start($timer, $after_1_seconds, $period_is_1_second, function($timer, $status){
729	echo "Hello\n";
730});
731
732uv_run();
733````
734
735
736### void uv_timer_stop(resource $timer)
737
738##### *Description*
739
740stop specified timer.
741
742##### *Parameters*
743
744*resource $timer*: uv timer resource.
745
746##### *Return Value*
747
748*long $retval*:
749
750##### *Example*
751
752````php
753<?php
754$timer = uv_timer_init();
755uv_timer_start($timer, 100, 100, function($timer, $status){
756	echo "Hello\n";
757	uv_timer_stop($timer);
758});
759
760uv_run();
761````
762
763
764### void uv_timer_again(resource $timer)
765
766##### *Description*
767
768restart timer.
769
770##### *Parameters*
771
772*resource $timer*: uv_timer resource.
773
774##### *Return Value*
775
776*void*:
777
778##### *Example*
779
780
781
782### void uv_timer_set_repeat(resource $timer, long $repeat)
783
784##### *Description*
785
786set repeat count.
787
788##### *Parameters*
789
790*resource $uv_timer*: uv_timer resource
791
792*long $repeat*: repeat count
793
794##### *Return Value*
795
796*void*:
797
798##### *Example*
799
800
801
802### long uv_timer_get_repeat(resource $timer)
803
804##### *Description*
805
806returns repeat interval.
807
808##### *Parameters*
809
810*resource $uv_timer*: uv_timer resource
811
812##### *Return Value*
813
814*long $repeat_time*:
815
816##### *Example*
817
818
819
820### resource uv_idle_init([resource $loop])
821
822##### *Description*
823
824initialize uv idle handle.
825
826##### *Parameters*
827
828*resource $loop*: uv_loop resource.
829
830##### *Return Value*
831
832*resource $idle*: initialized idle handle.
833
834##### *Example*
835
836````php
837<?php
838$loop = uv_default_loop();
839$idle = uv_idle_init($loop);
840````
841
842
843
844### void uv_idle_start(resource $idle, callable $callback)
845
846##### *Description*
847
848start idle callback.
849
850##### *Parameters*
851
852*resource $idle*: uv_idle resource.
853*callable $callback*: idle callback.
854
855##### *Return Value*
856
857*long result*:
858
859##### *Example*
860
861````php
862<?php
863$loop = uv_default_loop();
864$idle = uv_idle_init();
865
866$i = 0;
867uv_idle_start($idle, function($idle_handle, $stat) use (&$i){
868    echo "count: {$i}" . PHP_EOL;
869    $i++;
870
871    if ($i > 3) {
872        uv_idle_stop($idle);
873    }
874    sleep(1);
875});
876
877uv_run();
878````
879
880
881
882### void uv_idle_stop(resource $idle)
883
884##### *Description*
885
886stop idle callback.
887
888##### *Parameters*
889
890*resource $idle*: uv_idle resource.
891
892##### *Return Value*
893
894*long result*:
895
896##### *Example*
897
898````php
899<?php
900$loop = uv_default_loop();
901$idle = uv_idle_init();
902
903$i = 0;
904uv_idle_start($idle, function($idle_handle, $stat) use (&$i){
905    echo "count: {$i}" . PHP_EOL;
906    $i++;
907
908    if ($i > 3) {
909        uv_idle_stop($idle);
910    }
911    sleep(1);
912});
913
914uv_run();
915````
916
917
918
919### void uv_getaddrinfo(resource $loop, callable $callback, string $node, string $service, array $hints)
920
921
922### resource uv_tcp_init([resource $loop])
923
924##### *Description*
925
926create a tcp socket.
927
928##### *Parameters*
929
930*resource $loop*: loop resource or null. if not specified loop resource then use uv_default_loop resource.
931
932##### *Return Value*
933
934*resource php_uv*: uv resource which initialized for tcp.
935
936##### *Example*
937
938````php
939<?php
940$tcp = uv_tcp_init();
941````
942
943
944
945### resource uv_default_loop()
946
947##### *Description*
948
949return default loop handle.
950
951##### *Parameters*
952
953##### *Return Value*
954
955*resource $loop*:
956
957##### *Example*
958
959````php
960<?php
961$loop = uv_default_loop();
962````
963
964
965
966### resource uv_loop_new()
967
968##### *Description*
969
970create a new loop handle.
971
972##### *Parameters*
973
974##### *Return Value*
975
976*resource $loop*:
977
978##### *Example*
979
980````php
981<?php
982$loop = uv_loop_new();
983````
984
985
986
987### resource uv_udp_init([resource $loop])
988
989##### *Description*
990
991create a udp socket.
992
993##### *Parameters*
994
995*resource $loop*: loop resource or null. if not specified loop resource then use uv_default_loop resource.
996
997##### *Return Value*
998
999*resource php_uv*: uv resource which initialized for udp.
1000
1001##### *Example*
1002
1003````php
1004<?php
1005$udp = uv_udp_init();
1006````
1007
1008
1009
1010### void uv_udp_bind(resource $resource, resource $address, long $flags)
1011
1012##### *Description*
1013
1014listens for a connection on a uv udp handle.
1015
1016##### *Parameters*
1017
1018*resource $handle*: uv resource handle (udp)
1019
1020*resource $uv_ip_addr*: uv sockaddr(ipv4) resource.
1021
1022*long $flags*: unused.
1023
1024##### *Return Value*
1025
1026*void *:
1027
1028##### *Example*
1029
1030````php
1031<?php
1032$udp = uv_udp_init();
1033var_dump($udp);
1034
1035uv_udp_bind($udp, uv_ip4_addr('0.0.0.0',10000));
1036
1037uv_udp_recv_start($udp,function($stream, $nread, $buffer){
1038    echo "recv:" .  $buffer;
1039
1040    uv_close($stream);
1041});
1042
1043$uv = uv_udp_init();
1044uv_udp_send($uv, "Hello", uv_ip4_addr("0.0.0.0",10000),function($uv, $s){
1045    echo "success" . PHP_EOL;
1046    uv_close($uv);
1047});
1048
1049uv_run();
1050````
1051
1052
1053
1054### void uv_udp_bind6(resource $resource, resource $address, long $flags)
1055
1056##### *Description*
1057
1058listens for a connection on a uv udp handle.
1059
1060##### *Parameters*
1061
1062*resource $handle*: uv resource handle (udp)
1063
1064*resource $uv_ip_addr*: uv sockaddr(ipv6) resource.
1065
1066*long $flags*: Should be 0 or UV::UDP_IPV6ONLY
1067
1068##### *Return Value*
1069
1070*void *:
1071
1072##### *Example*
1073
1074````php
1075<?php
1076$udp = uv_udp_init();
1077var_dump($udp);
1078
1079uv_udp_bind6($udp, uv_ip6_addr('::1',10000));
1080
1081uv_udp_recv_start($udp,function($stream, $nread, $buffer){
1082    echo "recv:" .  $buffer;
1083
1084    uv_close($stream);
1085});
1086
1087$uv = uv_udp_init();
1088uv_udp_send6($uv, "Hello", uv_ip6_addr("::1",10000),function($uv, $s){
1089    echo "success" . PHP_EOL;
1090    uv_close($uv);
1091});
1092
1093uv_run();
1094````
1095
1096
1097
1098### void uv_udp_recv_start(resource $handle, callable $callback)
1099
1100##### *Description*
1101
1102start receive callback.
1103
1104##### *Parameters*
1105
1106*resource $handle*: uv resource handle (udp)
1107
1108*callable $callback*: this callback parameter expects (resource $stream, long $nread, string $buffer).
1109
1110##### *Return Value*
1111
1112*void *:
1113
1114##### *Example*
1115
1116````php
1117<?php
1118$udp = uv_udp_init();
1119var_dump($udp);
1120
1121uv_udp_bind6($udp, uv_ip6_addr('::1',10000));
1122
1123uv_udp_recv_start($udp,function($stream, $nread, $buffer){
1124    echo "recv:" .  $buffer;
1125
1126    uv_close($stream);
1127});
1128
1129$uv = uv_udp_init();
1130uv_udp_send6($uv, "Hello", uv_ip6_addr("::1",10000),function($uv, $s){
1131    echo "success" . PHP_EOL;
1132    uv_close($uv);
1133});
1134
1135uv_run();
1136````
1137
1138
1139
1140### void uv_udp_recv_stop(resource $handle)
1141
1142##### *Description*
1143
1144stop receive callback.
1145
1146##### *Parameters*
1147
1148*resource $handle*: uv resource handle (udp)
1149
1150##### *Return Value*
1151
1152*void *:
1153
1154
1155
1156### long uv_udp_set_membership(resource $handle, string $multicast_addr, string $interface_addr, long $membership)
1157
1158##### *Description*
1159
1160join or leave udp muticast group..
1161
1162##### *Parameters*
1163
1164*resource $handle*: uv resource handle (udp)
1165
1166*string $multicast_addr*: multicast address
1167
1168*string $interface_addr*: interface address
1169
1170*long $membership*: UV::JOIN_GROUP or UV::LEAVE_GROUP
1171
1172##### *Return Value*
1173
1174*long *: result code
1175
1176##### *Example*
1177
1178
1179
1180### void uv_udp_set_multicast_loop(resource $handle, long $enabled)
1181
1182##### *Description*
1183
1184set multicast loop
1185
1186##### *Parameters*
1187
1188*resource $handle*: uv resource handle (udp)
1189
1190*long $enabled*:
1191
1192##### *Return Value*
1193
1194*void*:
1195
1196##### *Example*
1197
1198
1199
1200### void uv_udp_set_multicast_ttl(resource $handle, long $ttl)
1201
1202##### *Description*
1203
1204set multicast ttl
1205
1206##### *Parameters*
1207
1208*resource $handle*: uv resource handle (udp)
1209
1210*long $ttl*: multicast ttl
1211
1212##### *Return Value*
1213
1214*void*:
1215
1216##### *Example*
1217
1218
1219
1220### void uv_udp_set_broadcast(resource $handle, bool $enabled)
1221
1222##### *Description*
1223
1224set udp broadcast
1225
1226##### *Parameters*
1227
1228*resource $handle*: uv resource handle (udp)
1229
1230*long $enabled*:
1231
1232##### *Return Value*
1233
1234*void*:
1235
1236##### *Example*
1237
1238
1239
1240### void uv_udp_send(resource $handle, string $data, resource $uv_addr, callable $callback)
1241
1242##### *Description*
1243
1244send buffer to specified address.
1245
1246##### *Parameters*
1247
1248*resource $handle*: uv resource handle (udp)
1249
1250*string $data*: data
1251
1252*resource uv_addr*: uv_ip4_addr
1253
1254*callable $callback*: this callback parameter expects (resource $stream, long $status).
1255
1256##### *Return Value*
1257
1258*void *:
1259
1260##### *Example*
1261
1262````php
1263<?php
1264$udp = uv_udp_init();
1265var_dump($udp);
1266
1267uv_udp_bind($udp, uv_ip4_addr('::1',10000));
1268
1269uv_udp_recv_start($udp,function($stream, $nread, $buffer){
1270    echo "recv:" .  $buffer;
1271
1272    uv_close($stream);
1273});
1274
1275$uv = uv_udp_init();
1276uv_udp_send($uv, "Hello", uv_ip4_addr("::1",10000),function($uv, $s){
1277    echo "success" . PHP_EOL;
1278    uv_close($uv);
1279});
1280
1281uv_run();
1282````
1283
1284
1285### void uv_udp_send6(resource $handle, string $data, resource $uv_addr6, callable $callback)
1286
1287##### *Description*
1288
1289send buffer to specified address.
1290
1291##### *Parameters*
1292
1293*resource $handle*: uv resource handle (udp)
1294
1295*string $data*: data
1296
1297*resource uv_addr*: uv_ip6_addr
1298
1299*callable $callback*: this callback parameter expects (resource $stream, long $status).
1300
1301##### *Return Value*
1302
1303*void *:
1304
1305##### *Example*
1306
1307````php
1308<?php
1309$udp = uv_udp_init();
1310var_dump($udp);
1311
1312uv_udp_bind6($udp, uv_ip6_addr('::1',10000));
1313
1314uv_udp_recv_start($udp,function($stream, $nread, $buffer){
1315    echo "recv:" .  $buffer;
1316
1317    uv_close($stream);
1318});
1319
1320$uv = uv_udp_init();
1321uv_udp_send6($uv, "Hello", uv_ip6_addr("::1",10000),function($uv, $s){
1322    echo "success" . PHP_EOL;
1323    uv_close($uv);
1324});
1325
1326uv_run();
1327````
1328
1329
1330### bool uv_is_active(resource $handle)
1331
1332
1333### bool uv_is_readable(resource $handle)
1334
1335
1336### bool uv_is_writable(resource $handle)
1337
1338
1339### bool uv_walk(resource $loop, callable $closure[, array $opaque])
1340
1341##### *TODO*
1342
1343* implement this.
1344
1345
1346
1347### long uv_guess_handle(resource $uv)
1348
1349
1350### long uv_handle_type(resource $uv)
1351
1352##### *Description*
1353
1354returns current uv type. (this is not libuv function. util for php-uv)
1355
1356##### *Parameters*
1357
1358*resource $uv_handle*: uv_handle
1359
1360##### *Return Value*
1361
1362*long $handle_type*: should return UV::IS_UV_* constatns. e.g) UV::IS_UV_TCP
1363
1364##### *Example*
1365
1366````php
1367<?php
1368$tcp = uv_tcp_init();
1369var_dump(uv_handle_type($tcp));
1370````
1371
1372##### *Note*
1373
1374* this may change.
1375
1376
1377
1378### resource uv_pipe_init(resource $loop, long $ipc)
1379
1380##### *Description*
1381
1382initialize pipe resource
1383
1384##### *Parameters*
1385
1386*resource $uv_loop*: uv_loop resource
1387
1388*bool $ipc*: when this pipe use for ipc, please set true otherwise false.
1389
1390##### *Return Value*
1391
1392*resource $uv_pipe*:
1393
1394##### *Example*
1395
1396````php
1397<?php
1398$pipe = uv_pipe_init(uv_default_loop(), true);
1399````
1400
1401
1402
1403### void uv_pipe_open(resource $handle, long $pipe)
1404
1405##### *Description*
1406
1407open a pipe resource.
1408
1409##### *Parameters*
1410
1411*resource $uv_handle*: uv pipe handle
1412
1413*long $pipe: dunnno. maybe file descriptor.
1414
1415##### *Return Value*
1416
1417*void*:
1418
1419##### *Example*
1420
1421
1422
1423### long uv_pipe_bind(resource $handle, string $name)
1424
1425##### *Description*
1426
1427create a named pipe.
1428
1429##### *Parameters*
1430
1431*resource $uv_handle*: uv pipe handle
1432
1433*long $pipe: dunnno. maybe file descriptor.
1434
1435##### *Return Value*
1436
1437*void*:
1438
1439##### *Example*
1440
1441
1442
1443### void uv_pipe_connect(resource $handle, string $path, callable $callback)
1444
1445##### *Description*
1446
1447connect to named pipe.
1448
1449##### *Parameters*
1450
1451*resource $uv_handle*: uv pipe handle
1452
1453*string $path: named pipe path
1454
1455*callable $callback: this callback parameter expects (resource $pipe, long $status)
1456
1457##### *Return Value*
1458
1459*void*:
1460
1461##### *Example*
1462
1463````php
1464<?php
1465b = uv_pipe_init(uv_default_loop(), 0);
1466uv_pipe_connect($b, PIPE_PATH, function($a,$b){
1467    uv_write($b,"Hello", function($stream,$stat){
1468        uv_close($stream);
1469    });
1470});
1471
1472uv_run();
1473````
1474
1475
1476
1477### void uv_pipe_pending_instances(resource $handle, long $count)
1478
1479
1480### resource uv_ares_init_options(resource $loop, array $options, long $optmask)
1481
1482
1483### void ares_gethostbyname(resource $handle, string $name, long $flag, callable $callback)
1484
1485
1486### array uv_loadavg(void)
1487
1488##### *Description*
1489
1490retunrs current loadaverage.
1491
1492##### *Parameters*
1493
1494##### *Return Value*
1495
1496*array $loadaverage*:
1497
1498##### *Example*
1499
1500````php
1501<?php
1502var_dump(uv_loadavg());
1503//array(3) {
1504//  [0]=>
1505//  float(1.7421875)
1506//  [1]=>
1507//  float(1.427734375)
1508//  [2]=>
1509//  float(1.3955078125)
1510//}
1511````
1512
1513##### *Note*
1514
1515returns array on windows box. (does not support load average on windows)
1516
1517
1518
1519### double uv_uptime(void)
1520
1521##### *Description*
1522
1523returns current uptime.
1524
1525##### *Parameters*
1526
1527##### *Return Value*
1528
1529*long $uptime*:
1530
1531##### *Example*
1532
1533````php
1534<?php
1535var_dump(uv_uptime());
1536//float(1247516)
1537````
1538
1539
1540
1541### long uv_get_free_memory(void)
1542
1543##### *Description*
1544
1545returns current free memory size.
1546
1547##### *Parameters*
1548
1549##### *Return Value*
1550
1551*long $free*:
1552
1553##### *Example*
1554
1555````php
1556<?php
1557var_dump(uv_get_free_memory());
1558//int(135860224)
1559````
1560
1561
1562
1563### long uv_get_total_memory(void)
1564
1565##### *Description*
1566
1567returns total memory size.
1568
1569##### *Parameters*
1570
1571##### *Return Value*
1572
1573*long $free*:
1574
1575##### *Example*
1576
1577````php
1578<?php
1579var_dump(uv_get_total_memory());
1580//int(8589934592)
1581````
1582
1583
1584
1585### long uv_hrtime(void)
1586
1587##### *TODO*
1588
1589check implmentation
1590
1591
1592
1593### string uv_exepath(void)
1594
1595##### *Description*
1596
1597returns current exepath. basically this will returns current php path.
1598
1599##### *Parameters*
1600
1601##### *Return Value*
1602
1603*string $exepath*:
1604
1605##### *Example*
1606
1607````php
1608<?php
1609var_dump(uv_exepath());
1610//string(53) "/Users/chobie/.phpenv/versions/5.4.1-zts-goto/bin/php"
1611```
1612
1613
1614
1615### string uv_cwd(void)
1616
1617##### *Description*
1618
1619returns current working directory.
1620
1621##### *Parameters*
1622
1623##### *Return Value*
1624
1625*string $cwd*:
1626
1627##### *Example*
1628
1629````php
1630<?php
1631var_dump(uv_cwd());
1632//string(24) "/Users/chobie/src/php-uv"
1633````
1634
1635
1636
1637### array uv_cpu_info(void)
1638
1639##### *Description*
1640
1641returns current cpu informations
1642
1643.
1644
1645##### *Parameters*
1646
1647##### *Return Value*
1648
1649*array $cpu_info*:
1650
1651##### *Example*
1652
1653````php
1654<?php
1655var_dump(uv_cpu_info());
1656//array(8) {
1657//  [0]=>
1658//  array(3) {
1659//    ["model"]=>
1660//    string(13) "MacBookPro8,2"
1661//    ["speed"]=>
1662//    int(2200)
1663//    ["times"]=>
1664//    array(5) {
1665//      ["sys"]=>
1666//      int(69952140)
1667//      ["user"]=>
1668//      int(38153450)
1669//      ["idle"]=>
1670//      int(776709120)
1671//      ["irq"]=>
1672//      int(0)
1673//      ["nice"]=>
1674//      int(0)
1675//    }
1676//  }...
1677````
1678
1679
1680
1681### array uv_interface_addresses(void)
1682
1683### resource uv_stdio_new(zval $fd, long $flags)
1684
1685### resource uv_spawn(resource $loop, string $command, array $args, array $stdio, string $cwd, array $env = array(), callable $callback [,long $flags,  array $options])
1686
1687
1688### void uv_process_kill(resource $handle, long $signal)
1689
1690##### *Description*
1691
1692send signal to specified uv process resource.
1693
1694##### *Parameters*
1695
1696*resource $handle*: uv resource handle (process)
1697
1698*long $signal*:
1699
1700##### *Return Value*
1701
1702*void*:
1703
1704##### *Example*
1705
1706
1707
1708### void uv_kill(long $pid, long $signal)
1709
1710##### *Description*
1711
1712send signal to specified pid.
1713
1714##### *Parameters*
1715
1716*long $pid*: process id
1717
1718*long $signal*:
1719
1720##### *Return Value*
1721
1722*void*:
1723
1724##### *Example*
1725
1726
1727
1728### bool uv_chdir(string $directory)
1729
1730##### *Description*
1731
1732change working directory.
1733
1734##### *Parameters*
1735
1736*string $directory*:
1737
1738##### *Return Value*
1739
1740*bool *:
1741
1742##### *Example*
1743
1744
1745
1746### resource uv_rwlock_init(void)
1747
1748##### *Description*
1749
1750initialize rwlock resource
1751
1752##### *Parameters*
1753
1754##### *Return Value*
1755
1756*resource $rwlock*: returns uv rwlock resource
1757
1758##### *Example*
1759
1760
1761
1762### uv_rwlock_rdlock(resource $handle)
1763
1764##### *Description*
1765
1766set read lock
1767
1768##### *Parameters*
1769
1770*resource $handle*: uv resource handle (uv rwlock)
1771
1772##### *Return Value*
1773
1774*void *:
1775
1776##### *Example*
1777
1778
1779
1780### bool uv_rwlock_tryrdlock(resource $handle)
1781
1782##### *TODO*
1783
1784* implemnt this correctly
1785
1786
1787
1788### void uv_rwlock_rdunlock(resource $handle)
1789
1790##### *Description*
1791
1792unlock read lock
1793
1794##### *Parameters*
1795
1796*resource $handle*: uv resource handle (uv rwlock)
1797
1798##### *Return Value*
1799
1800*void*:
1801
1802##### *Example*
1803
1804
1805
1806### uv_rwlock_wrlock(resource $handle)
1807
1808##### *Description*
1809
1810set write lock
1811
1812##### *Parameters*
1813
1814*resource $handle*: uv resource handle (uv rwlock)
1815
1816##### *Return Value*
1817
1818*void *:
1819
1820##### *Example*
1821
1822
1823
1824### uv_rwlock_trywrlock(resource $handle)
1825
1826##### *TODO*
1827
1828* implement this correctly
1829
1830
1831
1832### uv_rwlock_wrunlock(resource $handle)
1833
1834##### *Description*
1835
1836unlock write lock
1837
1838##### *Parameters*
1839
1840*resource $handle*: uv resource handle (uv rwlock)
1841
1842##### *Return Value*
1843
1844*void*:
1845
1846##### *Example*
1847
1848
1849
1850### uv_lock uv_mutex_init(void)
1851
1852##### *Description*
1853
1854initialize mutex resource
1855
1856##### *Parameters*
1857
1858##### *Return Value*
1859
1860*resource $uv_mutex*: uv mutex resource
1861
1862##### *Example*
1863
1864
1865
1866### void uv_mutex_lock(uv_lock $lock)
1867
1868##### *Description*
1869
1870lock mutex
1871
1872##### *Parameters*
1873
1874*resource $handle*: uv resource handle (uv mutex)
1875
1876##### *Return Value*
1877
1878*void*:
1879
1880##### *Example*
1881
1882
1883
1884### bool uv_mutex_trylock(uv_lock $lock)
1885
1886##### *TODO*
1887
1888* implement this correctly
1889
1890
1891
1892### uv_lock uv_sem_init(long $value)
1893
1894##### *Description*
1895
1896initialize semaphore resource
1897
1898##### *Parameters*
1899
1900##### *Return Value*
1901
1902*resource $uv_sem*:
1903
1904##### *Example*
1905
1906
1907
1908### void uv_sem_post(uv_lock $sem)
1909
1910##### *Description*
1911
1912post semaphore
1913
1914##### *Parameters*
1915
1916*resource $handle*: uv resource handle (uv sem)
1917
1918##### *Return Value*
1919
1920*void*:
1921
1922##### *Example*
1923
1924
1925
1926### void uv_sem_wait(uv_lock $sem)
1927
1928##### *Todo*
1929
1930* implemnt this correctly
1931
1932
1933
1934### void uv_sem_trywait(uv_lock $sem)
1935
1936##### *Todo*
1937
1938* implment this correctly
1939
1940
1941
1942### resource uv_prepare_init(resource $loop)
1943
1944##### *Description*
1945
1946initialize prepare resource
1947
1948##### *Parameters*
1949
1950*resource $loop*: uv loop handle
1951
1952##### *Return Value*
1953
1954*resource $uv_prepare*:
1955
1956##### *Example*
1957
1958````php
1959<?php
1960$prepare = uv_prepare_init(uv_default_loop());
1961````
1962
1963
1964
1965### void uv_prepare_start(resource $handle, callable $callback)
1966
1967##### *Description*
1968
1969setup prepare loop callback. (pre loop callback)
1970
1971##### *Parameters*
1972
1973*resource $handle*: uv resource handle (prepare)
1974
1975*callable $callback*: this callback parameter expects (resource $prepare, long $status).
1976
1977##### *Return Value*
1978
1979*long *:
1980
1981##### *Example*
1982````php
1983
1984<?php
1985$loop = uv_default_loop();
1986$prepare = uv_prepare_init($loop);
1987
1988uv_prepare_start($prepare, function($rsc, $status){
1989    echo "Hello";
1990    uv_unref($rsc);
1991});
1992
1993uv_run();
1994````
1995
1996
1997### void uv_prepare_stop(resource $handle)
1998
1999##### *Description*
2000
2001stop prepare callback
2002
2003##### *Parameters*
2004
2005*resource $prepare*: uv resource handle (prepare)
2006
2007##### *Return Value*
2008
2009*long*:
2010
2011
2012
2013### resource uv_check_init([resource $loop])
2014
2015##### *Description*
2016
2017setup check resource
2018
2019##### *Parameters*
2020
2021*resource $loop*: uv loop handle
2022
2023##### *Return Value*
2024
2025*resource uv_check*:
2026
2027##### *Example*
2028````php
2029<?php
2030$check = uv_check_init(uv_default_loop());
2031````
2032
2033
2034### void uv_check_start(resource $handle, callable $callback)
2035
2036##### *Description*
2037
2038stats check loop callback. (after loop callback)
2039
2040##### *Parameters*
2041
2042*resource $handle*: uv resource handle (check)
2043
2044*callable $callback*: this callback parameter expects (resource $check, long $status).
2045
2046##### *Return Value*
2047
2048*long *:
2049
2050##### *Example*
2051````php
2052<?php
2053$loop = uv_default_loop();
2054$check = uv_check_init($loop);
2055
2056$idle = uv_idle_init();
2057
2058$i = 0;
2059uv_idle_start($idle, function($stat) use (&$i, $idle, $loop){
2060    echo "count: {$i}" . PHP_EOL;
2061    $i++;
2062
2063    if ($i > 3) {
2064        uv_idle_stop($idle);
2065    }
2066    sleep(1);
2067});
2068
2069uv_check_start($check, function($check, $status){
2070    echo "Hello";
2071    uv_check_stop($check);
2072});
2073
2074uv_run();
2075````
2076
2077
2078### void uv_check_stop(resource $handle)
2079
2080##### *Description*
2081
2082stop check callback
2083
2084##### *Parameters*
2085
2086*resource $check*: uv resource handle (check)
2087
2088##### *Return Value*
2089
2090*void *:
2091
2092
2093
2094### resource uv_async_init(resource $loop, callable $callback)
2095
2096##### *Description*
2097
2098setup async callback
2099
2100##### *Parameters*
2101
2102*resource $loop*: uv loop resource
2103
2104*callback $callback*:
2105
2106##### *Return Value*
2107
2108*resource *: uv async resource
2109
2110##### *Example*
2111
2112
2113
2114### void uv_async_send(resource $handle)
2115
2116##### *Description*
2117
2118send async callback immidiately
2119
2120##### *Parameters*
2121
2122*resource $handle*: uv async handle
2123
2124##### *Return Value*
2125
2126*void*:
2127
2128##### *Example*
2129
2130
2131### void uv_queue_work(resource $loop, callable $callback, callable $after_callback)
2132
2133##### *Description*
2134
2135execute callbacks in another thread (requires Thread Safe enabled PHP)
2136
2137
2138### resource uv_fs_open(resource $loop, string $path, long $flag, long $mode, callable $callback)
2139
2140##### *Description*
2141
2142open specified file
2143
2144##### *Parameters*
2145
2146*resource $loop*: uv_loop resource.
2147
2148*string $path*: file path
2149
2150*long $flag*: file flag. this should be UV::O_RDONLY and some constants flag.
2151
2152*long $mode*: mode flag. this should be UV::S_IRWXU and some mode flag.
2153
2154*callable $calback*: this callback parameter expects (resource $stream)
2155
2156
2157##### *Return Value*
2158
2159*void*:
2160
2161##### *Example*
2162
2163````php
2164<?php
2165uv_fs_open(uv_default_loop(),"/tmp/hello",
2166    UV::O_WRONLY | UV::O_CREAT | UV::O_APPEND,
2167    UV::S_IRWXU | UV::S_IRUSR,
2168    function($r){
2169
2170    uv_fs_write(uv_default_loop(),$r,"hello",0, function($a) use ($r){
2171        uv_fs_fdatasync(uv_default_loop(),$r,function(){
2172            echo "fsync finished";
2173        });
2174    });
2175});
2176
2177uv_run();
2178````
2179
2180
2181
2182### void uv_fs_read(resource $loop, zval $fd, long $offset, long $length, callable $callback)
2183
2184##### *Description*
2185
2186async read.
2187
2188##### *Parameters*
2189
2190*resource $loop*: uv loop handle
2191
2192*zval $fd*: this expects long $fd, resource $php_stream or resource $php_socket.
2193
2194*long $offset*: the offset position in the file at which reading should commence.
2195
2196*long $length*: the length in bytes that should be read starting at position *$offset*.
2197
2198*resource $callback*: this callback parameter expects (zval $fd, long $nread, string $buffer).
2199
2200##### *Return Value*
2201
2202*void *:
2203
2204
2205
2206### void uv_fs_close(resource $loop, zval $fd, callable $callback)
2207
2208##### *Description*
2209
2210close specified file descriptor.
2211
2212##### *Parameters*
2213
2214*resource $loop*: uv_loop resource.
2215
2216*zval $fd*: file descriptor. this expects long $fd, resource $php_stream or resource $php_socket.
2217
2218*callable $calback*: this callback parameter expects (resource $stream)
2219
2220##### *Return Value*
2221
2222*void*:
2223
2224##### *Example*
2225
2226##### *todo*
2227
2228* handling PHP's stream and socket correctly.
2229
2230
2231
2232### void uv_fs_write(resource $loop, zval $fd, string $buffer, long $offset, callable $callback)
2233
2234##### *Description*
2235
2236write buffer to specified file descriptor.
2237
2238##### *Parameters*
2239
2240*resource $loop*: uv_loop resource.
2241
2242*zval $fd*: file descriptor. this expects long $fd, resource $php_stream or resource $php_socket.
2243
2244*string $buffer*: buffer.
2245
2246*callable $calback*: this callback parameter expects (resource $stream, long $result)
2247
2248##### *Return Value*
2249
2250*void*:
2251
2252##### *Example*
2253
2254
2255
2256### void uv_fs_fsync(resource $loop, zval $fd, callable $callback)
2257
2258##### *Description*
2259
2260async fsync
2261
2262##### *Parameters*
2263
2264*resource $handle*: uv loop handle
2265
2266*zval $fd*:
2267
2268
2269*callable $callback*:
2270
2271##### *Return Value*
2272
2273*void*:
2274
2275##### *Example*
2276
2277
2278
2279### void uv_fs_fdatasync(resource $loop, zval $fd, callable $callback)
2280
2281##### *Description*
2282
2283async fdatasync
2284
2285##### *Parameters*
2286
2287*resource $handle*: uv loop handle
2288
2289*zval $fd*:
2290
2291*callable $callback*:
2292
2293##### *Return Value*
2294
2295*void*:
2296
2297##### *Example*
2298
2299
2300### void uv_fs_ftruncate(resource $loop, zval $fd, long $offset, callable $callback)
2301
2302##### *Description*
2303
2304async ftruncate
2305
2306##### *Parameters*
2307
2308*resource $handle*: uv loop handle
2309
2310*zval $fd*:
2311
2312*long $offset*:
2313
2314*callable $callback*:
2315
2316##### *Return Value*
2317
2318*void*:
2319
2320##### *Example*
2321
2322
2323### void uv_fs_mkdir(resource $loop, string $path, long $mode, callable $callback)
2324
2325##### *Description*
2326
2327async mkdir
2328
2329##### *Parameters*
2330
2331*resource $handle*: uv loop handle
2332
2333*string $path*:
2334
2335*long $mode*:
2336
2337*callable $callback*:
2338
2339##### *Return Value*
2340
2341*void*:
2342
2343##### *Example*
2344
2345
2346### void uv_fs_rmdir(resource $loop, string $path, callable $callback)
2347
2348##### *Description*
2349
2350async rmdir
2351
2352##### *Parameters*
2353
2354*resource $handle*: uv loop handle
2355
2356*string $path*:
2357
2358*callable $callback*:
2359
2360##### *Return Value*
2361
2362*void*:
2363
2364##### *Example*
2365
2366
2367### void uv_fs_unlink(resource $loop, string $path, callable $callback)
2368
2369##### *Description*
2370
2371async unlink
2372
2373##### *Parameters*
2374
2375*resource $handle*: uv loop handle
2376
2377*string $path*:
2378
2379*callable $callback*:
2380
2381##### *Return Value*
2382
2383*void*:
2384
2385##### *Example*
2386
2387
2388### void uv_fs_rename(resource $loop, string $from, string $to, callable $callback)
2389
2390##### *Description*
2391
2392async rename
2393
2394##### *Parameters*
2395
2396*resource $handle*: uv loop handle
2397
2398*string $from*:
2399
2400*string $to*:
2401
2402*callable $callback*:
2403
2404##### *Return Value*
2405
2406*void*:
2407
2408##### *Example*
2409
2410
2411
2412### void uv_fs_utime(resource $loop, string $path, long $utime, long $atime, callable $callback)
2413
2414##### *Description*
2415
2416async utime
2417
2418##### *Parameters*
2419
2420*resource $handle*: uv loop handle
2421
2422*string $path*:
2423
2424*long $utime*:
2425
2426*long $atime*:
2427
2428*callable $callback*:
2429
2430##### *Return Value*
2431
2432*void*:
2433
2434##### *Example*
2435
2436
2437
2438### void uv_fs_futime(resource $loop, zval $fd, long $utime, long $atime callable $callback)
2439
2440##### *Description*
2441
2442async futime
2443
2444##### *Parameters*
2445
2446*resource $handle*: uv loop handle
2447
2448*zval $fd*:
2449
2450*long $utime*:
2451
2452*long $atime*:
2453
2454*callable $callback*:
2455
2456##### *Return Value*
2457
2458*void*:
2459
2460##### *Example*
2461
2462
2463### void uv_fs_chmod(resource $loop, string $path, long $mode, callable $callback)
2464
2465##### *Description*
2466
2467async chmod
2468
2469##### *Parameters*
2470
2471*resource $handle*: uv loop handle
2472
2473*string $path*:
2474
2475*long $mode*:
2476
2477*callable $callback*:
2478
2479##### *Return Value*
2480
2481*void*:
2482
2483##### *Example*
2484
2485
2486### void uv_fs_fchmod(resource $loop, zval $fd, long $mode, callable $callback)
2487
2488##### *Description*
2489
2490async fchmod
2491
2492##### *Parameters*
2493
2494*resource $handle*: uv loop handle
2495
2496*zval $fd*:
2497
2498*long $mode*:
2499
2500*callable $callback*:
2501
2502##### *Return Value*
2503
2504*void*:
2505
2506##### *Example*
2507
2508
2509### void uv_fs_chown(resource $loop, string $path, long $uid, long $gid, callable $callback)
2510
2511##### *Description*
2512
2513async chown
2514
2515##### *Parameters*
2516
2517*resource $handle*: uv loop handle
2518
2519*string $paht*:
2520
2521*long $uid*:
2522
2523*long $gid*:
2524
2525*callable $callback*:
2526
2527##### *Return Value*
2528
2529*void*:
2530
2531##### *Example*
2532
2533
2534### void uv_fs_fchown(resource $loop, zval $fd, long $uid, $long $gid, callable $callback)
2535
2536##### *Description*
2537
2538async fchown
2539
2540##### *Parameters*
2541
2542*resource $handle*: uv loop handle
2543
2544*zval $fd*:
2545
2546*long $uid*:
2547
2548*long $gid*:
2549
2550*callable $callback*:
2551
2552##### *Return Value*
2553
2554*void*:
2555
2556##### *Example*
2557
2558
2559### void uv_fs_link(resource $loop, string $from, string $to, callable $callback)
2560
2561##### *Description*
2562
2563async link
2564
2565##### *Parameters*
2566
2567*resource $handle*: uv loop handle
2568
2569*string $from*:
2570
2571*string $to*:
2572
2573*callable $callback*:
2574
2575##### *Return Value*
2576
2577*void*:
2578
2579##### *Example*
2580
2581
2582### void uv_fs_symlink(resource $loop, string $from, string $to, long $flags, callable $callback)
2583
2584##### *Description*
2585
2586async symlink
2587
2588##### *Parameters*
2589
2590*resource $handle*: uv loop handle
2591
2592*string $from*:
2593
2594*string $to*:
2595
2596*long $flags*:
2597
2598*callable $callback*:
2599
2600##### *Return Value*
2601
2602*void*:
2603
2604##### *Example*
2605
2606
2607### void uv_fs_readlink(resource $loop, string $path, callable $callback)
2608
2609##### *Description*
2610
2611async readlink
2612
2613##### *Parameters*
2614
2615*resource $handle*: uv loop handle
2616
2617*string $path*:
2618
2619*callable $callback*:
2620
2621##### *Return Value*
2622
2623*void*:
2624
2625##### *Example*
2626
2627
2628### void uv_fs_stat(resource $loop, string $path, callable $callback)
2629
2630##### *Description*
2631
2632async stat
2633
2634##### *Parameters*
2635
2636*resource $handle*: uv loop handle
2637
2638*string $path*:
2639
2640*callable $callback*: this callback parameter expects (resource $stream, array $stat)
2641
2642##### *Return Value*
2643
2644*void*:
2645
2646##### *Example*
2647
2648
2649
2650### void uv_fs_lstat(resource $loop, string $path, callable $callback)
2651
2652##### *Description*
2653
2654async lstat
2655
2656##### *Parameters*
2657
2658*resource $handle*: uv loop handle
2659
2660*string $path*:
2661
2662*callable $callback*:
2663
2664##### *Return Value*
2665
2666*void*:
2667
2668##### *Example*
2669
2670
2671
2672### void uv_fs_fstat(resource $loop, zval $fd, callable $callback)
2673
2674##### *Description*
2675
2676async fstat
2677
2678##### *Parameters*
2679
2680*resource $handle*: uv loop handle
2681
2682*zval $fd*:
2683
2684*callable $callback*:
2685
2686##### *Return Value*
2687
2688*void*:
2689
2690##### *Example*
2691
2692
2693
2694### uv_fs_readdir(resource $loop, string $path, long $flags, callable $callback)
2695
2696##### *Description*
2697
2698async readdir
2699
2700##### *Parameters*
2701
2702*resource $handle*: uv loop handle
2703
2704*string $path*:
2705
2706*long $flags*:
2707
2708*callable $callback*:
2709
2710##### *Return Value*
2711
2712*void*:
2713
2714##### *Example*
2715
2716
2717### void uv_fs_sendfile(resource $loop, zval $in_fd, zval $out_fd, long $offset, long $length, callable $callback)
2718
2719##### *Description*
2720
2721async sendfile
2722
2723##### *Parameters*
2724
2725*resource $handle*: uv loop handle
2726
2727*zval $in_fd*:
2728
2729*zval $out_fd*:
2730
2731*long $offset*:
2732
2733*long $length*:
2734
2735*callable $callback*:
2736
2737##### *Return Value*
2738
2739*void*:
2740
2741##### *Example*
2742
2743
2744### resource uv_fs_event_init(resource $loop, string $path, callable $callback, long $flags = 0)
2745
2746##### *Description*
2747
2748initialize fs event.
2749
2750##### *Parameters*
2751
2752*resource $handle*: uv loop handle
2753
2754*string $path*:
2755
2756*callable $callback*:
2757
2758##### *Return Value*
2759
2760*void*:
2761
2762##### *Example*
2763
2764
2765
2766### resource uv_tty_init(resource $loop, zval $fd, long $readable)
2767
2768##### *Description*
2769
2770initialize tty resource. you have to open tty your hand.
2771
2772##### *Parameters*
2773
2774*resource $handle*: uv loop handle
2775
2776*zval $fd*:
2777
2778*long $readable*:
2779
2780##### *Return Value*
2781
2782*resource $uv_tty*:
2783
2784##### *Example*
2785
2786
2787
2788### long uv_tty_get_winsize(resource $tty, long &$width, long &$height)
2789
2790
2791### long uv_tty_set_mode(resource $tty, long $mode)
2792
2793
2794### void uv_tty_reset_mode(void)
2795
2796
2797### string uv_tcp_getsockname(resource $uv_sockaddr)
2798
2799
2800### string uv_tcp_getpeername(resource $uv_sockaddr)
2801
2802
2803### string uv_udp_getsockname(resource $uv_sockaddr)
2804
2805
2806### long uv_resident_set_memory(void)
2807
2808
2809### string uv_ip4_name(resource uv_sockaddr $address)
2810
2811
2812### string uv_ip6_name(resource uv_sockaddr $address)
2813
2814
2815### uv uv_poll_init([resource $uv_loop], zval fd)
2816
2817##### *Description*
2818
2819initialize poll
2820
2821##### *Parameters*
2822
2823*resource $uv_loop*: uv_loop resource.
2824
2825*mixed $fd*: this expects long fd, PHP's stream or PHP's socket resource.
2826
2827##### *Return Value*
2828
2829*resource uv*: uv resource which initialized poll.
2830
2831##### *Example*
2832
2833````php
2834<?php
2835$fd = fopen("php://stdout","w+");
2836
2837$poll = uv_poll_init(uv_default_loop(), $fd);
2838
2839````
2840
2841##### *Note*
2842
2843* some platform doesn't support file descriptor on these method.
2844
2845
2846### uv uv_poll_start(resource $handle, $events, $callback)
2847
2848##### *Description*
2849
2850start polling
2851
2852##### *Parameters*
2853
2854*resource $poll*: uv poll resource.
2855
2856*long $events*: UV::READBLE and UV::WRITABLE flags.
2857
2858*callable $callback*: this callback parameter expects (resource $poll, long $status, long $events, mixed $connection). the connection parameter passes uv_poll_init'd fd.
2859
2860##### *Return Value*
2861
2862*void*:
2863
2864##### *Example*
2865
2866````php
2867<?php
2868$fd = fopen("php://stdout","w+");
2869
2870$poll = uv_poll_init(uv_default_loop(), $fd);
2871uv_poll_start($poll, UV::WRITABLE, function($poll, $stat, $ev, $conn){
2872        fwrite($conn, "Hello");
2873        fclose($conn);
2874        uv_poll_stop($poll);
2875});
2876
2877uv_run();
2878````
2879
2880##### *Note*
2881
2882* if you want to use a socket. please use uv_poll_init_socket instead of this. Windows can't handle socket with this function.
2883
2884
2885
2886### void uv_poll_stop(resource $poll)
2887
2888
2889### uv uv_fs_poll_init([resource $uv_loop])
2890
2891
2892### uv uv_fs_poll_start(resource $handle, $callback, string $path, long $interval)
2893
2894
2895### void uv_fs_poll_stop(resource $poll)
2896
2897
2898### void uv_stop([resource $uv_loop])
2899
2900##### *Description*
2901
2902##### *Parameters*
2903
2904*resource $uv_loop*: uv loop handle
2905
2906##### *Return Value*
2907
2908*void*:
2909
2910##### *Example*
2911
2912
2913### resource uv_signal_init([resource $uv_loop])
2914
2915##### *Description*
2916
2917##### *Parameters*
2918
2919*resource $uv_loop*: uv loop handle
2920
2921##### *Return Value*
2922
2923*resource*:
2924
2925##### *Example*
2926
2927### void uv_signal_start(resource $sig_handle, callable $sig_callback, int $sig_num)
2928
2929##### *Description*
2930
2931##### *Parameters*
2932
2933*resource $sig_handle*:
2934
2935*callable $callable*: signal callback
2936
2937*int $sig_num*: signal
2938
2939##### *Return Value*
2940
2941*void*:
2942
2943##### *Example*
2944
2945### int uv_signal_stop(resource $sig_handle)
2946
2947##### *Description*
2948
2949##### *Parameters*
2950
2951*resource $sig_handle*:
2952
2953##### *Return Value*
2954
2955*int $sig_num*:
2956
2957##### *Example*
2958
2959