extra: cleanup some example servers, allow port to be specified on command line.

char-rename
John Benediktsson 2017-01-30 09:30:08 -08:00
parent 39811fc7e7
commit ecdb8dfe62
3 changed files with 19 additions and 16 deletions

View File

@ -1,7 +1,8 @@
! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel io io.encodings.binary io.servers ;
USING: accessors command-line io io.encodings.binary io.servers
kernel math.parser namespaces sequences ;
IN: echo-server
@ -14,9 +15,8 @@ IN: echo-server
"echo.server" >>name
[ echo-loop ] >>handler ;
: echod ( port -- server )
<echo-server> start-server ;
: echo-server-main ( -- )
command-line get [ 1234 ] [ first string>number ] if-empty
<echo-server> start-server wait-for-server ;
: echod-main ( -- ) 1234 echod drop ;
MAIN: echod-main
MAIN: echo-server-main

View File

@ -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 kernel threads ;
USING: accessors calendar calendar.format command-line io
io.encodings.ascii io.servers kernel math.parser namespaces
sequences threads ;
IN: time-server
: handle-time-client ( -- )
now timestamp>rfc822 print ;
: <time-server> ( -- threaded-server )
: <time-server> ( port -- threaded-server )
ascii <threaded-server>
"time-server" >>name
1234 >>insecure
swap >>insecure
[ handle-time-client ] >>handler ;
: start-time-server ( -- )
<time-server> start-server drop ;
: time-server-main ( -- )
command-line get [ 1234 ] [ first string>number ] if-empty
<time-server> start-server wait-for-server ;
MAIN: start-time-server
MAIN: time-server-main

View File

@ -1,5 +1,5 @@
USING: accessors debugger kernel listener io.servers
io.encodings.utf8 namespaces ;
USING: accessors command-line debugger io.encodings.utf8
io.servers kernel listener math.parser namespaces sequences ;
IN: tty-server
@ -14,6 +14,7 @@ IN: tty-server
f >>timeout ;
: run-tty-server ( -- )
9999 <tty-server> start-server drop ;
command-line get [ 9999 ] [ first string>number ] if-empty
<tty-server> start-server wait-for-server ;
MAIN: run-tty-server