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{ inet4 f "8.8.8.8" 0 } ] [ "8.8.8.8" 0 <inet> ] unit-test
14 [ T{ inet6 f "5:5:5:5:6:6:6:6" 0 } ] [ "5:5:5:5:6:6:6:6" 0 <inet> ] unit-test
17 [ "1.2.3.4" T{ inet4 } inet-pton ] unit-test
20 [ B{ 1 2 3 4 } T{ inet4 } inet-ntop ] unit-test
23 [ B{ 255 255 255 255 } T{ inet4 } inet-ntop ] unit-test
25 [ B{ 255 255 255 255 } ]
26 [ "255.255.255.255" T{ inet4 } inet-pton ] unit-test
28 [ B{ 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 } ]
29 [ "1:2:3:4:5:6:7:8" T{ inet6 } inet-pton ] unit-test
32 [ B{ 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 } T{ inet6 } inet-ntop ] unit-test
34 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } ]
35 [ "::" T{ inet6 } inet-pton ] unit-test
37 [ f T{ inet6 } inet-pton ] [ reason>> empty-ipv6? ] must-fail-with
40 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } T{ inet6 } inet-ntop ] unit-test
42 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } ]
43 [ "1::" T{ inet6 } inet-pton ] unit-test
45 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } ]
46 [ "::1" T{ inet6 } inet-pton ] unit-test
48 [ B{ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 } ]
49 [ "::100" T{ inet6 } inet-pton ] unit-test
51 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 2 } ]
52 [ "1::2" T{ inet6 } inet-pton ] unit-test
54 [ B{ 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 3 } ]
55 [ "1::2:3" T{ inet6 } inet-pton ] unit-test
57 [ B{ 0 1 0 2 0 0 0 0 0 0 0 0 0 3 0 4 } ]
58 [ "1:2::3:4" T{ inet6 } inet-pton ] unit-test
61 [ B{ 0 1 0 2 0 0 0 0 0 0 0 0 0 3 0 4 } T{ inet6 } inet-ntop ] unit-test
63 [ B{ 0 0 0 0 0 0 0 0 0 127 0 0 0 0 0 1 } ]
64 [ "::127.0.0.1" T{ inet6 } inet-pton ] unit-test
66 [ B{ 0 2 0 0 0 0 0 9 0 127 0 0 0 0 0 1 } ]
67 [ "2::9:127.0.0.1" T{ inet6 } inet-pton ] unit-test
69 [ "2001:6f8:37a:5:0:0:0:1" ]
70 [ "2001:6f8:37a:5::1" T{ inet6 } [ inet-pton ] [ inet-ntop ] bi ] unit-test
73 "localhost" 80 <inet> resolve-host
75 [ [ [ inet4? ] [ inet6? ] bi or ] all? ] bi
79 "localhost" resolve-host
81 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
87 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
91 f 0 <inet> resolve-host
93 [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
97 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram1" set ] unit-test
98 [ ] [ "datagram1" get addr>> "addr1" set ] unit-test
99 [ f ] [ "addr1" get port>> 0 = ] unit-test
101 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram2" set ] unit-test
102 [ ] [ "datagram2" get addr>> "addr2" set ] unit-test
103 [ f ] [ "addr2" get port>> 0 = ] unit-test
105 [ ] [ B{ 1 2 3 4 } "addr2" get "datagram1" get send ] unit-test
106 [ B{ 1 2 3 4 } ] [ "datagram2" get receive "from" set ] unit-test
107 [ ] [ B{ 4 3 2 1 } "from" get "datagram2" get send ] unit-test
108 [ B{ 4 3 2 1 } t ] [ "datagram1" get receive "addr2" get = ] unit-test
110 [ ] [ "datagram1" get dispose ] unit-test
111 [ ] [ "datagram2" get dispose ] unit-test
114 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram3" set ] unit-test
116 [ ] [ 1 seconds "datagram3" get set-timeout ] unit-test
117 [ "datagram3" get receive ] must-fail
119 ! See what happens if other end is closed
120 [ ] [ <promise> "port" set ] unit-test
122 [ ] [ "datagram3" get dispose ] unit-test
126 "127.0.0.1" 0 <inet4> utf8 <server>
127 dup addr>> "port" get fulfill
130 dup stream-readln drop
131 "hello" <string-reader> swap stream-copy
133 ] "Socket close test" spawn drop
137 "port" get ?promise utf8 [
138 1 seconds input-stream get set-timeout
139 1 seconds output-stream get set-timeout
140 "hi\n" write flush readln readln
144 ! Binding to all interfaces should work
145 [ ] [ f 0 <inet4> <datagram> dispose ] unit-test
146 [ ] [ f 0 <inet6> <datagram> dispose ] unit-test