@@ -85,7 +85,9 @@ function startListener($master, $listener)
85
85
} catch (React \Socket \ConnectionException $ exception ) {
86
86
$ reason = 'Address already in use ' ;
87
87
88
- if (strpos ($ exception ->getMessage (), $ reason ) === false ) {
88
+ $ isPortSpecified = $ listener [4 ];
89
+
90
+ if ($ isPortSpecified || strpos ($ exception ->getMessage (), $ reason ) === false ) {
89
91
throw $ exception ;
90
92
}
91
93
@@ -119,8 +121,17 @@ try {
119
121
120
122
$ listeners = [];
121
123
foreach ([$ servers , $ secures ] as $ type => $ group ) {
124
+ $ isSecure = $ type === 1 ;
122
125
foreach ($ group as $ i => $ server ) {
123
126
list ($ host , $ port ) = explode (': ' , $ server , 2 ) + [1 => '' ];
127
+
128
+ if ($ port === '' ) {
129
+ $ port = $ isSecure ? '44300 ' : '8000 ' ;
130
+ $ isPortSpecified = false ;
131
+ } else {
132
+ $ isPortSpecified = true ;
133
+ }
134
+
124
135
$ ip = filter_var (gethostbyname ($ host ), FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 );
125
136
$ regex = '/\A(?:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\z/ ' ;
126
137
if ($ ip === false || !preg_match ($ regex , $ port )) {
@@ -129,7 +140,7 @@ try {
129
140
if (isset ($ listeners [$ server ])) {
130
141
throw new \RuntimeException ("Duplicated entry: $ server " );
131
142
}
132
- $ listeners [$ server ] = [$ host , $ port , $ type === 1 , $ cert ];
143
+ $ listeners [$ server ] = [$ host , $ port , $ isSecure , $ cert, $ isPortSpecified ];
133
144
}
134
145
}
135
146
0 commit comments