@@ -16,6 +16,8 @@ and [`Stream`](https://github.com/reactphp/stream) components.
1616 * [ connection event] ( #connection-event )
1717 * [ error event] ( #error-event )
1818 * [ getAddress()] ( #getaddress )
19+ * [ pause()] ( #pause )
20+ * [ resume()] ( #resume )
1921 * [ close()] ( #close )
2022 * [ Server] ( #server )
2123 * [ SecureServer] ( #secureserver )
@@ -134,6 +136,61 @@ $port = parse_url('tcp://' . $address, PHP_URL_PORT);
134136echo 'Server listening on port ' . $port . PHP_EOL;
135137```
136138
139+ #### pause()
140+
141+ The ` pause(): void ` method can be used to
142+ pause accepting new incoming connections.
143+
144+ Removes the socket resource from the EventLoop and thus stop accepting
145+ new connections. Note that the listening socket stays active and is not
146+ closed.
147+
148+ This means that new incoming connections will stay pending in the
149+ operating system backlog until its configurable backlog is filled.
150+ Once the backlog is filled, the operating system may reject further
151+ incoming connections until the backlog is drained again by resuming
152+ to accept new connections.
153+
154+ Once the server is paused, no futher ` connection ` events SHOULD
155+ be emitted.
156+
157+ ``` php
158+ $server->pause();
159+
160+ $server->on('connection', assertShouldNeverCalled());
161+ ```
162+
163+ This method is advisory-only, though generally not recommended, the
164+ server MAY continue emitting ` connection ` events.
165+
166+ Unless otherwise noted, a successfully opened server SHOULD NOT start
167+ in paused state.
168+
169+ You can continue processing events by calling ` resume() ` again.
170+
171+ Note that both methods can be called any number of times, in particular
172+ calling ` pause() ` more than once SHOULD NOT have any effect.
173+ Similarly, calling this after ` close() ` is a NO-OP.
174+
175+ #### resume()
176+
177+ The ` resume(): void ` method can be used to
178+ resume accepting new incoming connections.
179+
180+ Re-attach the socket resource to the EventLoop after a previous ` pause() ` .
181+
182+ ``` php
183+ $server->pause();
184+
185+ $loop->addTimer(1.0, function () use ($server) {
186+ $server->resume();
187+ });
188+ ```
189+
190+ Note that both methods can be called any number of times, in particular
191+ calling ` resume() ` without a prior ` pause() ` SHOULD NOT have any effect.
192+ Similarly, calling this after ` close() ` is a NO-OP.
193+
137194#### close()
138195
139196The ` close(): void ` method can be used to
0 commit comments