 
 : 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 ( -- )

    ] curry "Client handler" spawn drop server-loop ;

: simple-server ( -- )
    [
        "127.0.0.1" 0 <inet4> ascii <server>
        [ server set ]
        [ addr>> port>> port-promise get fulfill ]
        [ [ server-loop ] with-disposal ]
        tri
    ] ignore-errors ;

: simple-client ( -- )
    [

IN: benchmark.sockets

SYMBOL: counter
SYMBOL: server-promise
SYMBOL: server
SYMBOL: port

CONSTANT: number-of-requests 1000

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

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