factor/extra/benchmark/echo/echo.factor

21 lines
482 B
Factor
Raw Normal View History

2011-08-26 21:02:22 -04:00
! Copyright (C) 2011 John Benediktsson
2011-08-26 20:18:08 -04:00
! See http://factorcode.org/license.txt for BSD license
USING: accessors destructors kernel io.binary io.sockets
sequences ;
IN: benchmark.echo
: send/recv ( packet server client -- )
[ over over addr>> ] [ send ] bi* receive drop assert= ;
: udp-echo ( -- )
[
10000 iota [ 4 >be ] map
f 0 <inet4> <datagram>
f 0 <inet4> <datagram>
[ send/recv ] 2curry each
] with-destructors ;
MAIN: udp-echo