Paste: socket client
Author: | josh |
Mode: | factor |
Date: | Sat, 28 Feb 2009 03:49:17 |
Plain Text |
USING: kernel threads io io.sockets io.encodings.utf8 prettyprint math ;
IN: mudclient
: setup-streams ( object object -- object ) <inet> utf8 <client>
drop
dup
[
[
[ [ print "hello" print ] each-line t ] loop
] with-input-stream
] curry "input-thread" spawn
drop
;
: read-keyboard-loop ( object -- object )
[
[
[ yield readln dup [ write flush ] [ drop ] if t ] loop
] with-output-stream
] curry "output-thread" spawn
;
: runme ( -- object )
"mud.arctic.org" 2700 setup-streams read-keyboard-loop ;
MAIN: runme
New Annotation