io.sockets: f 0 <inet4> should work

db4
Slava Pestov 2010-09-04 15:41:12 -07:00
parent 4fc792629e
commit aa2f5ae13f
2 changed files with 20 additions and 3 deletions

View 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

View 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 ;