mirror of
https://github.com/janet-lang/janet
synced 2025-11-16 07:17:16 +00:00
Add net/listen and net/accept-loop.
These are the elements that make up net/server, which has been moved into pure Janet instead.
This commit is contained in:
@@ -2722,6 +2722,28 @@
|
||||
:on-status (or onsignal (make-onsignal env 1))
|
||||
:source "repl"}))
|
||||
|
||||
###
|
||||
###
|
||||
### Extras
|
||||
###
|
||||
###
|
||||
|
||||
(defmacro- guarddef
|
||||
[sym form]
|
||||
(if (dyn sym)
|
||||
form))
|
||||
|
||||
(guarddef net/listen
|
||||
(defn net/server
|
||||
"Start a server asynchornously with net/listen and net/accept-loop. Returns the new server stream."
|
||||
[host port &opt handler type]
|
||||
(def s (net/listen host port type))
|
||||
(if handler
|
||||
(ev/go (fn [] (net/accept-loop s handler))))
|
||||
s))
|
||||
|
||||
(undef guarddef)
|
||||
|
||||
###
|
||||
###
|
||||
### CLI Tool Main
|
||||
|
||||
Reference in New Issue
Block a user