Skip to content

Commit 6bf2b8a

Browse files
committed
TEST: raw TCP read example
related to: Oldes/Rebol-issues#1422
1 parent a90ee07 commit 6bf2b8a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/tests/test-raw-tcp-read.r3

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Rebol [
2+
Title: "Test raw TCP read"
3+
File: %test-raw-tcp-read.r3
4+
Note: {
5+
Based on original Carl's example which can be found at:
6+
http://web.archive.org/web/20130720122919/http://www.rebol.net/wiki/TCP_Port_Open_Issue
7+
}
8+
]
9+
http-request: {GET /robots.txt HTTP/1.1
10+
Host: www.rebol.com
11+
12+
}
13+
14+
wp: make port! tcp://www.rebol.com
15+
16+
wp/awake: func [event /local port] [
17+
port: event/port
18+
print [as-green "==TCP-event:" as-red event/type]
19+
switch/default event/type [
20+
read [print ["^/read:" length? port/data] read port]
21+
wrote [read port]
22+
lookup [print query port open port]
23+
connect [write port http-request]
24+
][true]
25+
]
26+
try [
27+
open wp
28+
either port? wait [wp 15][
29+
print to string! wp/data
30+
][
31+
print as-red "Timeout!"
32+
]
33+
close wp
34+
]
35+
print "DONE"
36+
wait 0:0:5

0 commit comments

Comments
 (0)