Skip to content

Instantly share code, notes, and snippets.

@gchiu
Created March 30, 2013 00:26
Show Gist options
  • Save gchiu/5274646 to your computer and use it in GitHub Desktop.
Save gchiu/5274646 to your computer and use it in GitHub Desktop.
A net-utils like confirm function for R3
confirm: func [ tcp-port [port!] challenge [string!] code [string!]
/local data
][
write tcp-port challenge
tcp-port/awake: func [ event ][
tcp-port: event/port
switch/default event/type [
wrote [
read tcp-port
false
]
read [
data: enline to-string tcp-port/data
true
]
][ true ]
]
wait tcp-port
reduce [ find/part data length? code data ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment