Updates docs and news.
This commit is contained in:
parent
5eaec84785
commit
b2fd562983
6 changed files with 211 additions and 85 deletions
|
|
@ -13,13 +13,19 @@ import rawsockets
|
|||
export TPort
|
||||
|
||||
## AsyncDispatch
|
||||
## --------
|
||||
## -------------
|
||||
##
|
||||
## This module implements a brand new dispatcher based on Futures.
|
||||
## On Windows IOCP is used and on other operating systems the selectors module
|
||||
## is used instead.
|
||||
## On Windows IOCP is used and on other operating systems the ``selectors``
|
||||
## module is used instead.
|
||||
##
|
||||
## **Note:** This module is still largely experimental.
|
||||
|
||||
|
||||
# TODO: Discarded void PFutures need to checked for exception.
|
||||
# TODO: Exceptions are currently uncatchable due to the limitation that
|
||||
# you cannot have yield in a try stmt. Perhaps I can get the macro to put
|
||||
# a user's try except around ``future.read``.
|
||||
|
||||
# -- Futures
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
#
|
||||
|
||||
## This module implements a high performance asynchronous HTTP server.
|
||||
##
|
||||
## **Note:** This module is still largely experimental.
|
||||
|
||||
import strtabs, asyncnet, asyncdispatch, parseutils, parseurl, strutils
|
||||
type
|
||||
|
|
|
|||
|
|
@ -6,6 +6,44 @@
|
|||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This module implements a high-level asynchronous sockets API based on the
|
||||
## asynchronous dispatcher defined in the ``asyncdispatch`` module.
|
||||
##
|
||||
## Example
|
||||
## =======
|
||||
##
|
||||
## The following example demonstrates a simple chat server.
|
||||
##
|
||||
## .. code-block::nimrod
|
||||
##
|
||||
## import asyncnet, asyncdispatch
|
||||
##
|
||||
## var clients: seq[PAsyncSocket] = @[]
|
||||
##
|
||||
## proc processClient(client: PAsyncSocket) {.async.} =
|
||||
## while true:
|
||||
## let line = await client.recvLine()
|
||||
## for c in clients:
|
||||
## await c.send(line & "\c\L")
|
||||
##
|
||||
## proc serve() {.async.} =
|
||||
## var server = newAsyncSocket()
|
||||
## server.bindAddr(TPort(12345))
|
||||
## server.listen()
|
||||
##
|
||||
## while true:
|
||||
## let client = await server.accept()
|
||||
## clients.add client
|
||||
##
|
||||
## processClient(client)
|
||||
##
|
||||
## serve()
|
||||
## runForever()
|
||||
##
|
||||
##
|
||||
## **Note:** This module is still largely experimental.
|
||||
|
||||
import asyncdispatch
|
||||
import rawsockets
|
||||
import net
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue