]> gitweb.factorcode.org Git - factor.git/blob - core/io/server.facts
more sql changes
[factor.git] / core / io / server.facts
1 USING: help io ;
2
3 HELP: log-stream
4 { $var-description "Holds an output stream for logging messages." }
5 { $see-also log-error log-client with-log-file with-logging } ;
6
7 HELP: log-message
8 { $values { "str" "a string" } }
9 { $description "Logs a message to the log stream. If " { $link log-stream } " is not set, logs to the " { $link stdio } " stream." }
10 { $see-also log-error log-client } ;
11
12 HELP: log-error
13 { $values { "str" "a string" } }
14 { $description "Logs an error message." }
15 { $see-also log-message log-client } ;
16
17 HELP: log-client
18 { $values { "client" "a client socket stream" } }
19 { $description "Logs an incoming client connection." }
20 { $see-also log-message log-error } ;
21
22 HELP: with-log-file
23 { $values { "path" "a string" } { "quot" "a quotation" } }
24 { $description "Calls the quotation in a new dynamic scope where the " { $link log-stream } " is set to a file output stream writing to " { $snippet "path" } "." } ;
25
26 HELP: with-logging
27 { $values { "quot" "a quotation" } }
28 { $description "Calls the quotation in a new dynamic scope where the " { $link log-stream } " is set to the " { $link stdio } " stream " { $emphasis "at this point in time" } "." } ;
29
30 HELP: with-client
31 { $values { "quot" "a quotation" } { "client" "a client socket stream" } }
32 { $description "Logs a client connection and spawns a new thread that calls the quotation, with the " { $link stdio } " stream set to the client stream. If the quotation throws an error, the client connection is closed, and the error is printed to the " { $link stdio } " stream at the time the thread was spawned." } ;
33
34 HELP: server-stream
35 { $var-description "Current server socket, set by " { $link with-server } "." } ;
36
37 HELP: with-server
38 { $values { "port" "an integer from 0 to 65535" } { "ident" "a symbol" } { "quot" "a quotation" } }
39 { $description "Starts a TCP/IP server. The quotation is called in a new thread for each client connection, with the client connection being the " { $link stdio } " stream. Client connections are logged to the " { $link stdio } " stream at the time the server was started."
40 $terpri
41 "The socket server is stored in the " { $snippet "ident" } " variable. If " { $link with-server } " was called inside a new thread, this allows other threads to stop the server by passing the variable value to " { $link stream-close } "." } ;