source socketserver.lsp
Module: SocketServer
Author: Jeff Ober
Version: 1.1
Location: http://static.artfulcode.net/newlisp/socketserver.lsp
Generic, extensible socket server using net-select.
Version history
1.1 • added set-handler function 1.0 • initial release- § - SocketServer:serve
syntax: (SocketServer:serve port [ip [mode [max-clients [select-hook]]]])
parameter: port - port parameter, passed to net-listen
parameter: ip - optional ip parameter, passed to net-listen
parameter: mode - optional mode parameter, passed to net-listen
parameter: max-clients - optional integer representing the maximum number of clients to queue for service at once
parameter: select-hook - optional function that is evaluated while waiting for the next client connection
SocketServer:serve initializes the socket server. The server runs in a while true loop.
example:(SocketServer:serve 10000 127.0.0.1 "" 10)- § - SocketServer:set-handler
syntax: (SocketServer:set-handler fn-handler)
parameter: fn-handler - response handler function
Sets the response handling function that receives the unparsed client request. Function should evaluate to a string. The default handler is echo-handler, a function that returns the unaltered request back to the client (for debugging purposes).
example:(SocketServer:set-handler (fn (req) request)) ; "echo" handler- ∂ -
Artful Code
generated with newLISP and newLISPdoc