#:port port
#:path (list '/ id)))
+(define address->string uri->string)
+(define string->address uri-reference)
+
(define (make-local-address . args)
(make-address this-host
this-port
(define (send-network-message address . message)
(let ((s (udp-open-socket))
- (machine (address-machine address)))
+ (machine (address-machine address))
+ (packet (with-output-to-string)
+ (lambda ()
+ (print (cons (address->string address) message)))))
(udp-bind! s #f 0)
(udp-connect! s
(machine-host machine)
(machine-port machine))
- (udp-send s message)
+ (udp-send s packet)
(udp-close-socket s)))
(define (next-local-message)
(let-values (((n str) (udp-recv s 1024)))
(print "Received " n " bytes over network: " str)
(match (with-input-from-string str read)
- ((uri-str message ...)
- (apply send-message (cons (uri-reference uri-str) message)))
+ ((addr-str message ...)
+ (apply send-message (cons (string->address addr-str) message)))
(else
(print "Warning: received badly formatted message string '" str "'"))))
(loop))))))
(start-network-listener)
(start-console)
+(define (boot-sam host port)
+ (start-scheduler))
+
;; (thread-join! scheduler-thread)
+
+(define (main)
+ (let loop ((args (cdr (argv)))
+ (host "localhost")
+ (port 8000))
+ (match args
+ ((or "-h" "--help")
+ (print-usage))
+ (((or "-p" "--port") pstr rest ...)
+ (loop rest host (string->number pstr)))
+ (("--hostname" hstr rest ...)
+ (loop rest hstr port))
+ (()
+ (boot-sam host port)))))