}
{ $description "Sends a packet one time to the address and closes the sending datagram port." } ;
-HELP: send-n-times
-{ $values
- { "bytes" byte-array } { "addrspec" "an address specifier" } { "n" integer }
-}
-{ $examples
- "Send a datagram 10 times to localhost, port 7777:"
- { $example "USING: io.sockets prettyprint ;"
- "B{ 1 2 3 } f 7777 <inet4> 10 send-n-times"
- ""
- }
-}
-{ $description "Sends a packet n times to the address and closes the sending datagram port." } ;
-
HELP: broadcast-once
{ $values
{ "bytes" byte-array } { "addrspec" "an address specifier" }
}
{ $description "Broadcasts a packet one time to the address and closes the sending broadcast port." } ;
-HELP: broadcast-n-times
-{ $values
- { "bytes" byte-array } { "addrspec" "an address specifier" } { "n" integer }
-}
-{ $examples
- "Broadcast a datagram 10 times to localhost, port 7777:"
- { $example "USING: io.sockets prettyprint ;"
- "B{ 1 2 3 } f 7777 <inet4> 10 broadcast-n-times"
- ""
- }
-}
-{ $description "Broadcasts a packet n times to the address and closes the sending broadcast port." } ;
-
-
-
HELP: with-random-local-broadcast
{ $values
{ "quot" quotation }
: send-once ( bytes addrspec -- )
[ send ] with-random-local-datagram ;
-:: send-n-times ( bytes addrspec n -- )
- [
- n swap '[ bytes addrspec _ send ] times
- ] with-random-local-datagram ;
-
: broadcast-once ( bytes addrspec -- )
[ send ] with-random-local-broadcast ;
-:: broadcast-n-times ( bytes addrspec n -- )
- [
- n swap '[ bytes addrspec _ send ] times
- ] with-random-local-broadcast ;
-
MEMO: ipv6-supported? ( -- ? )
[ "::1" 0 <inet6> binary <server> dispose t ] [ drop f ] recover ;