Removed trans_comm.rs from the compiler. Updating aio/sio to work with the new chan and port system, started on a networking module for the standard library.

This commit is contained in:
Eric Holk
2011-08-15 16:54:02 -07:00
parent e33af7e0b5
commit cf2def46c1
34 changed files with 326 additions and 600 deletions

30
src/lib/net.rs Normal file
View File

@@ -0,0 +1,30 @@
import str;
import ivec;
import uint;
tag ip_addr {
ipv4(u8, u8, u8, u8);
}
fn format_addr(ip : ip_addr) -> str {
alt(ip) {
ipv4(a, b, c, d) {
#fmt("%u.%u.%u.%u",
a as uint,
b as uint,
c as uint,
d as uint)
}
_ { fail "Unsupported address type"; }
}
}
fn parse_addr(ip : str) -> ip_addr {
let parts = ivec::map(uint::from_str, str::split(ip, ".".(0)));
if ivec::len(parts) != 4u { fail "Too many dots in IP address"; }
for i in parts { if i > 255u { fail "Invalid IP Address part."; } }
ipv4(parts.(0) as u8,
parts.(1) as u8,
parts.(2) as u8,
parts.(3) as u8)
}