;;; Global constants
-(define scratchy-version "1.0.0")
+(define scratchy-version "1.0.1")
(define scratchy-footer
(conc "\n"
(define (server-loop listener config)
(let-values (((in-port out-port) (tcp-accept listener)))
- (let* ((line (read-line in-port))
- (selector (string-trim-both line)))
- (let-values (((local-ip remote-ip) (tcp-addresses in-port)))
- (print "Accepted connection from " remote-ip
- " on " (seconds->string))
- (condition-case
- (begin
- (with-output-to-port out-port
- (lambda ()
- (serve-selector (if (= (string-length selector) 0)
- "/"
- selector)
- config)))
- (print "... served selector '" selector "'. Closing connection."))
- (o (exn)
- (print-error-message o out-port)
- (print-error-message o)
- (print "Error while attempting to serve selector " selector ".")))))
+ (let-values (((local-ip remote-ip) (tcp-addresses in-port)))
+ (print "Accepted connection from " remote-ip
+ " on " (seconds->string)))
+ (condition-case
+ (let* ((line (read-line in-port))
+ (selector (string-trim-both line)))
+ (condition-case
+ (begin
+ (with-output-to-port out-port
+ (lambda ()
+ (serve-selector (if (= (string-length selector) 0)
+ "/"
+ selector)
+ config)))
+ (print "... served selector '" selector "'. Closing connection."))
+ (o (exn)
+ (print-error-message o out-port)
+ (print-error-message o)
+ (print "Error while attempting to serve selector " selector "."))))
+ (o (exn)
+ (print-error-message o)))
(close-input-port in-port)
(close-output-port out-port))
(server-loop listener config))