File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments