]> gitweb.factorcode.org Git - factor.git/commitdiff
io.sockets: f 0 <inet4> should work
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 4 Sep 2010 22:41:12 +0000 (15:41 -0700)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 4 Sep 2010 22:41:12 +0000 (15:41 -0700)
basis/io/sockets/sockets-tests.factor
basis/io/sockets/sockets.factor

index 87d4f1c0a9b0383a84f0145973e2d963a20fa38a..56939f484f406cac146b26a20fdec386a688a150 100644 (file)
@@ -70,6 +70,18 @@ io.streams.string ;
     [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
 ] unit-test
 
+[ t t ] [
+    f resolve-host
+    [ length 1 >= ]
+    [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
+] unit-test
+
+[ t t ] [
+    f 0 <inet> resolve-host
+    [ length 1 >= ]
+    [ [ [ ipv4? ] [ ipv6? ] bi or ] all? ] bi
+] unit-test
+
 ! Smoke-test UDP
 [ ] [ "127.0.0.1" 0 <inet4> <datagram> "datagram1" set ] unit-test
 [ ] [ "datagram1" get addr>> "addr1" set ] unit-test
@@ -117,3 +129,6 @@ io.streams.string ;
         "hi\n" write flush readln readln
     ] with-client
 ] unit-test
+
+! Binding to all interfaces should work
+[ ] [ f 0 <inet4> <datagram> dispose ] unit-test
index 07a60c2d6734b04127c72db8c0948e81e5ccfb0f..9a8b352a1bd69814c24dddf7baeb1c2e1b1daed3 100644 (file)
@@ -17,6 +17,8 @@ IN: io.sockets
 ! Addressing
 <PRIVATE
 
+UNION: ?string string POSTPONE: f ;
+
 GENERIC: protocol-family ( addrspec -- af )
 
 GENERIC: sockaddr-size ( addrspec -- n )
@@ -58,7 +60,7 @@ M: local present path>> "Unix domain socket: " prepend ;
 
 SLOT: port
 
-TUPLE: ipv4 { host string read-only } ;
+TUPLE: ipv4 { host ?string read-only } ;
 
 C: <ipv4> ipv4
 
@@ -115,7 +117,7 @@ M: inet4 parse-sockaddr ( sockaddr-in addrspec -- newaddrspec )
 M: inet4 present
     [ host>> ] [ port>> number>string ] bi ":" glue ;
 
-TUPLE: ipv6 { host string read-only } ;
+TUPLE: ipv6 { host ?string read-only } ;
 
 C: <ipv6> ipv6
 
@@ -322,7 +324,7 @@ SYMBOL: remote-address
 
 GENERIC: resolve-host ( addrspec -- seq )
 
-TUPLE: hostname host ;
+TUPLE: hostname { host ?string read-only } ;
 
 TUPLE: inet < hostname port ;