File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
src/Std/Internal/Http/Server Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,28 @@ private def handle
188188end Connection
189189
190190/--
191- Serve conection
191+ This is the entry point of the library. It is used to receive and send requests using an `Async`
192+ handler for a single connection. It can be used with a `TCP.Socket` or any other type that implements
193+ `ClientConnection` to create a simple HTTP server capable of handling multiple connections concurrently.
194+
195+ # Example
196+
197+ ```lean
198+ -- Create a TCP socket server instance
199+ let server ← Socket.Server.mk
200+ server.bind addr
201+ server.listen backlog
202+
203+ -- Enter an infinite loop to handle incoming client connections
204+ while true do
205+ -- Accept a new client connection.
206+ let client ← server.accept
207+
208+ -- Handle the client connection concurrently in the background `serveConnection` will process requests
209+ -- and handle failures using the provided callbacks and config
210+ background (serveConnection client onRequest onFailure config)
211+ ```
212+
192213-/
193214def serveConnection
194215 [ClientConnection t]
You can’t perform that action at this time.
0 commit comments