Paste: parallel-cleave

Author: josh
Mode: factor
Date: Sat, 28 Feb 2009 04:38:04
Plain Text |
"mud.arctic.org" 2700 <inet> utf8 <client> swap dup
{ 
 [ [ [ [ print ] each-line t ] loop ] with-input-stream ] 
 [ [ [ readln dup [ write flush ] [ drop ] if t ] loop ] with-output-stream ] 
} parallel-cleave

Annotation: fixed version

Author: slava
Mode: factor
Date: Sat, 28 Feb 2009 05:08:31
Plain Text |
Run ./factor -run=listener...

USING: io.encodings.utf8 io.sockets concurrency.combinators ;
"mud.arctic.org" 2700 <inet> utf8 <client> swap dup
{ 
 [ [ [ print flush ] each-line ] with-input-stream ] 
 [ [ [ print flush ] each-line ] with-output-stream ] 
} parallel-cleave

Annotation: better version

Author: slava
Mode: factor
Date: Sat, 28 Feb 2009 05:35:51
Plain Text |
USING: io.encodings io.encodings.8-bit io.encodings.binary io.sockets concurrency.combinators ;

: input-loop ( -- )
    [
        100 read-partial dup
        [ latin1 decode write flush t ] [ drop f ] if
    ] loop ;

: output-loop ( -- )
    latin1 encode-output [ print flush ] each-line ;

"mud.arctic.org" 2700 <inet> binary <client> swap dup
{ 
    [ [ input-loop ] with-input-stream ] 
    [ [ output-loop ] with-output-stream ] 
} parallel-cleave

Annotation: better input-loop

Author: slava
Mode: factor
Date: Sat, 28 Feb 2009 05:44:54
Plain Text |
: input-loop ( -- )
    100 read-partial dup
    [ latin1 decode write flush input-loop ] [ drop ] if ;

New Annotation

Summary:
Author:
Mode:
Body: