File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ public function __construct(LoopInterface $loop, $socket)
26
26
27
27
public function getAddress ()
28
28
{
29
- return stream_socket_get_name ($ this ->socket , false );
29
+ if ($ this ->socket !== false ) {
30
+ return stream_socket_get_name ($ this ->socket , false );
31
+ }
30
32
}
31
33
32
34
public function getPort ()
@@ -54,7 +56,9 @@ public function pause()
54
56
55
57
public function resume ()
56
58
{
57
- $ this ->loop ->addReadStream ($ this ->socket , array ($ this , 'onReceive ' ));
59
+ if ($ this ->socket !== false ) {
60
+ $ this ->loop ->addReadStream ($ this ->socket , array ($ this , 'onReceive ' ));
61
+ }
58
62
}
59
63
60
64
public function onReceive ($ message )
@@ -76,13 +80,18 @@ public function onReceive($message)
76
80
77
81
public function close ()
78
82
{
83
+ if ($ this ->socket === false ) {
84
+ return ;
85
+ }
86
+
79
87
$ this ->emit ('close ' , array ($ this ));
80
88
$ this ->pause ();
81
- $ this ->buffer ->close ();
82
- $ this ->removeAllListeners ();
83
89
84
- fclose ($ this ->socket );
85
90
$ this ->socket = false ;
91
+ $ this ->buffer ->close ();
92
+ fclose ($ this ->socket );
93
+
94
+ $ this ->removeAllListeners ();
86
95
}
87
96
88
97
private function sanitizeAddress ($ address )
You can’t perform that action at this time.
0 commit comments