 
 : clients ( n -- )
     dup pprint " clients: " write [
-        <promise> port-promise set
+        <promise> server-promise set
         dup <count-down> counter set
+        "127.0.0.1" 0 <inet4> ascii <server>
+        [ server set ] [ addr>> port>> port set ] bi
+
         [ simple-server ] "Simple server" spawn drop
-        yield yield
         [ [ simple-client ] "Simple client" spawn drop ] times
+
         counter get await
         stop-server
-        yield yield
+        server-promise get ?promise drop
     ] benchmark . flush ;
 
 : socket-benchmarks ( -- )

IN: benchmark.sockets

SYMBOL: counter
SYMBOL: port-promise
SYMBOL: server

CONSTANT: number-of-requests 1000

: server-addr ( -- addr )
    "127.0.0.1" port-promise get ?promise <inet4> ;

: server-loop ( server -- )
    dup accept drop [

! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel math threads io io.sockets
io.encodings.ascii io.streams.duplex debugger tools.time
