1 USING: io.sockets io.sockets.private sequences math tools.test
2 namespaces accessors kernel destructors calendar io.timeouts
3 io.encodings.utf8 io concurrency.promises threads
7 [ T{ inet4 f f 0 } ] [ f 0 <inet4> ] unit-test
8 [ T{ inet6 f f 0 } ] [ f 0 <inet6> ] unit-test
10 [ T{ inet f "google.com" f } ] [ "google.com" f <inet> ] unit-test
12 [ T{ inet f "google.com" 0 } ] [ "google.com" 0 <inet> ] unit-test
13 [ T{ inet f "google.com" 80 } ] [ "google.com" 0 <inet> 80 with-port ] unit-test
14 [ T{ inet4 f "8.8.8.8" 0 } ] [ "8.8.8.8" 0 <inet4> ] unit-test
15 [ T{ inet4 f "8.8.8.8" 53 } ] [ "8.8.8.8" 0 <inet4> 53 with-port ] unit-test
16 [ T{ inet6 f "5:5:5:5:6:6:6:6" 12 } ] [ "5:5:5:5:6:6:6:6" 0 <inet6> 12 with-port ] unit-test
18 [ T{ inet f "google.com" 80 } ] [ "google.com" 80 with-port ] unit-test
21 [ "1.2.3.4" T{ inet4 } inet-pton ] unit-test
24 [ B{ 1 2 3 4 } T{ inet4 } inet-ntop ] unit-test
27 [ B{ 255 255 255 255 } T{ inet4 } inet-ntop ] unit-test
29 [ B{ 255 255 255 255 } ]
30 [ "255.255.255.255" T{ inet4 } inet-pton ] unit-test
32 [ B{ 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 } ]
33 [ "1:2:3:4:5:6:7:8" T{ inet6 } inet-pton ] unit-test
36 [ B{ 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 } T{ inet6 } inet-ntop ] unit-test
38 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } ]
39 [ "::" T{ inet6 } inet-pton ] unit-test
42 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } T{ inet6 } inet-ntop ] unit-test
44 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } ]
45 [ "1::" T{ inet6 } inet-pton ] unit-test
47 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } ]
48 [ "::1" T{ inet6 } inet-pton ] unit-test
50 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 } ]
51 [ "::100" T{ inet6 } inet-pton ] unit-test
53 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 } ]
54 [ "1::2" T{ inet6 } inet-pton ] unit-test
56 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 3 } ]
57 [ "1::2:3" T{ inet6 } inet-pton ] unit-test
59 [ B{ 0 1 0 2 0 0 0 0 0 0 0 0 0 3 0 4 } ]
60 [ "1:2::3:4" T{ inet6 } inet-pton ] unit-test
63 [ B{ 0 1 0 2 0 0 0 0 0 0 0 0 0 3 0 4 } T{ inet6 } inet-ntop ] unit-test
65 [ B{ 0 0 0 0 0 0 0 0 0 127 0 0 0 0 0 1 } ]
66 [ "::127.0.0.1" T{ inet6 } inet-pton ] unit-test
68 [ B{ 0 2 0 0 0 0 0 9 0 127 0 0 0 0 0 1 } ]
69 [ "2::9:127.0.0.1" T{ inet6 } inet-pton ] unit-test
71 [ "2001:6f8:37a:5:0:0:0:1" ]
72 [ "2001:6f8:37a:5::1" T{ inet6 } [ inet-pton ] [ inet-ntop ] bi ] unit-test
75 "localhost" 80 <inet> resolve-host
77 [ [ [ inet4? ] [ inet6? ] bi or ] all? ] bi
81 "localhost" resolve-host
83 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
89 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
93 f 0 <inet> resolve-host
95 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
99 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram1" set ] unit-test
100 [ ] [ "datagram1" get addr>> "addr1" set ] unit-test
101 [ f ] [ "addr1" get port>> 0 = ] unit-test
103 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram2" set ] unit-test
104 [ ] [ "datagram2" get addr>> "addr2" set ] unit-test
105 [ f ] [ "addr2" get port>> 0 = ] unit-test
107 [ ] [ B{ 1 2 3 4 } "addr2" get "datagram1" get send ] unit-test
108 [ B{ 1 2 3 4 } ] [ "datagram2" get receive "from" set ] unit-test
109 [ ] [ B{ 4 3 2 1 } "from" get "datagram2" get send ] unit-test
110 [ B{ 4 3 2 1 } t ] [ "datagram1" get receive "addr2" get = ] unit-test
112 [ ] [ "datagram1" get dispose ] unit-test
113 [ ] [ "datagram2" get dispose ] unit-test
116 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram3" set ] unit-test
118 [ ] [ 1 seconds "datagram3" get set-timeout ] unit-test
119 [ "datagram3" get receive ] must-fail
121 ! See what happens if other end is closed
122 [ ] [ <promise> "port" set ] unit-test
124 [ ] [ "datagram3" get dispose ] unit-test
128 "127.0.0.1" 0 <inet4> utf8 <server>
129 dup addr>> "port" get fulfill
132 dup stream-readln drop
133 "hello" <string-reader> swap stream-copy
135 ] "Socket close test" spawn drop
139 "port" get ?promise utf8 [
140 1 seconds input-stream get set-timeout
141 1 seconds output-stream get set-timeout
142 "hi\n" write flush readln readln
146 ! Binding to all interfaces should work
147 [ ] [ f 0 <inet4> <datagram> dispose ] unit-test
148 [ ] [ f 0 <inet6> <datagram> dispose ] unit-test