X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=extra%2Ftime-server%2Ftime-server.factor;h=eb193006ecffe8e656de5a24945e020fd7dffb67;hp=500f0276d7919edbb3cc593a144eec5c8705ae8e;hb=HEAD;hpb=938f33c7862c973e11e75d8e6d35b8cc0405661e diff --git a/extra/time-server/time-server.factor b/extra/time-server/time-server.factor index 500f0276d7..eb193006ec 100644 --- a/extra/time-server/time-server.factor +++ b/extra/time-server/time-server.factor @@ -1,19 +1,21 @@ ! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors calendar calendar.format io io.encodings.ascii -io.servers.connection threads ; +! See https://factorcode.org/license.txt for BSD license. +USING: accessors calendar calendar.format command-line io +io.encodings.ascii io.servers kernel math.parser namespaces +sequences ; IN: time-server : handle-time-client ( -- ) now timestamp>rfc822 print ; -: ( -- threaded-server ) +: ( port -- threaded-server ) ascii "time-server" >>name - 1234 >>insecure + swap >>insecure [ handle-time-client ] >>handler ; -: start-time-server ( -- threaded-server ) - [ start-server ] in-thread ; +: time-server-main ( -- ) + command-line get [ 1234 ] [ first string>number ] if-empty + start-server wait-for-server ; -MAIN: start-time-server +MAIN: time-server-main