forked from rebolsource/r3
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
related to: Oldes/Rebol-issues#1803
- Loading branch information
Showing
4 changed files
with
50 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Rebol [ | ||
Title: "Test UDP client" | ||
File: %test-udp-client.r3 | ||
Note: https://github.com/Oldes/Rebol-issues/issues/1803 | ||
] | ||
|
||
; start test UDP server... | ||
launch probe to-real-file %test-udp-server.r3 | ||
|
||
; wait some time for server to boot... | ||
wait 0:0:0.1 | ||
|
||
stdout: system/ports/output | ||
|
||
; open port for output... | ||
port: open udp://127.0.0.1:1189 | ||
port/awake: func[event][ | ||
print ["[UDP Client] event:" event/type] | ||
;; console output is buffered and so messages could come out of order; | ||
;; to prevent it, just use the `flush`! | ||
flush stdout | ||
true | ||
] | ||
; wait for port to be opened (required on Windows!)... | ||
wait port | ||
|
||
write-udp: func[msg [string!]][ | ||
print ["[UDP Client] sending:" as-yellow mold msg] | ||
flush stdout ;= flush console buffer! | ||
write port msg | ||
] | ||
write-udp "Hello" | ||
write-udp "Rebol" | ||
wait 1 ;= pretending some work here... | ||
write-udp "I'm done!" | ||
write-udp "quit" | ||
|
||
either system/options/script [ | ||
ask as-red "CLIENT DONE" | ||
][ print as-red "CLIENT DONE" wait 0.5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.