File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 3
3
namespace Datagram ;
4
4
5
5
use React \EventLoop \LoopInterface ;
6
+ use \Exception ;
6
7
7
8
class Buffer
8
9
{
@@ -36,9 +37,16 @@ public function handleWrite()
36
37
list ($ data , $ remoteAddress ) = array_shift ($ this ->outgoing );
37
38
38
39
if ($ remoteAddress === null ) {
39
- fwrite ($ this ->socket , $ data );
40
+ // do not use fwrite() as it obeys the stream buffer size and
41
+ // packets are not to be split at 8kb
42
+ $ ret = @stream_socket_sendto ($ this ->socket , $ data );
40
43
} else {
41
- stream_socket_sendto ($ this ->socket , $ data , 0 , $ remoteAddress );
44
+ $ ret = @stream_socket_sendto ($ this ->socket , $ data , 0 , $ remoteAddress );
45
+ }
46
+
47
+ if ($ ret < 0 ) {
48
+ $ error = error_get_last ();
49
+ throw new Exception ('Unable to send packet: ' . $ error ['message ' ]);
42
50
}
43
51
44
52
if (!$ this ->outgoing ) {
You can’t perform that action at this time.
0 commit comments