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
41 [ f T{ inet6 } inet-pton ] [ reason>> empty-ipv6? ] must-fail-with
44 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } T{ inet6 } inet-ntop ] unit-test
46 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } ]
47 [ "1::" T{ inet6 } inet-pton ] unit-test
49 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } ]
50 [ "::1" T{ inet6 } inet-pton ] unit-test
52 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 } ]
53 [ "::100" T{ inet6 } inet-pton ] unit-test
55 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 } ]
56 [ "1::2" T{ inet6 } inet-pton ] unit-test
58 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 3 } ]
59 [ "1::2:3" T{ inet6 } inet-pton ] unit-test
61 [ B{ 0 1 0 2 0 0 0 0 0 0 0 0 0 3 0 4 } ]
62 [ "1:2::3:4" T{ inet6 } inet-pton ] unit-test
65 [ B{ 0 1 0 2 0 0 0 0 0 0 0 0 0 3 0 4 } T{ inet6 } inet-ntop ] unit-test
67 [ B{ 0 0 0 0 0 0 0 0 0 127 0 0 0 0 0 1 } ]
68 [ "::127.0.0.1" T{ inet6 } inet-pton ] unit-test
70 [ B{ 0 2 0 0 0 0 0 9 0 127 0 0 0 0 0 1 } ]
71 [ "2::9:127.0.0.1" T{ inet6 } inet-pton ] unit-test
73 [ "2001:6f8:37a:5:0:0:0:1" ]
74 [ "2001:6f8:37a:5::1" T{ inet6 } [ inet-pton ] [ inet-ntop ] bi ] unit-test
77 "localhost" 80 <inet> resolve-host
79 [ [ [ inet4? ] [ inet6? ] bi or ] all? ] bi
83 "localhost" resolve-host
85 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
91 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
95 f 0 <inet> resolve-host
97 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
101 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram1" set ] unit-test
102 [ ] [ "datagram1" get addr>> "addr1" set ] unit-test
103 [ f ] [ "addr1" get port>> 0 = ] unit-test
105 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram2" set ] unit-test
106 [ ] [ "datagram2" get addr>> "addr2" set ] unit-test
107 [ f ] [ "addr2" get port>> 0 = ] unit-test
109 [ ] [ B{ 1 2 3 4 } "addr2" get "datagram1" get send ] unit-test
110 [ B{ 1 2 3 4 } ] [ "datagram2" get receive "from" set ] unit-test
111 [ ] [ B{ 4 3 2 1 } "from" get "datagram2" get send ] unit-test
112 [ B{ 4 3 2 1 } t ] [ "datagram1" get receive "addr2" get = ] unit-test
114 [ ] [ "datagram1" get dispose ] unit-test
115 [ ] [ "datagram2" get dispose ] unit-test
118 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram3" set ] unit-test
120 [ ] [ 1 seconds "datagram3" get set-timeout ] unit-test
121 [ "datagram3" get receive ] must-fail
123 ! See what happens if other end is closed
124 [ ] [ <promise> "port" set ] unit-test
126 [ ] [ "datagram3" get dispose ] unit-test
130 "127.0.0.1" 0 <inet4> utf8 <server>
131 dup addr>> "port" get fulfill
134 dup stream-readln drop
135 "hello" <string-reader> swap stream-copy
137 ] "Socket close test" spawn drop
141 "port" get ?promise utf8 [
142 1 seconds input-stream get set-timeout
143 1 seconds output-stream get set-timeout
144 "hi\n" write flush readln readln
148 ! Binding to all interfaces should work
149 [ ] [ f 0 <inet4> <datagram> dispose ] unit-test
150 [ ] [ f 0 <inet6> <datagram> dispose ] unit-test