Skip to content

Commit b65e0a6

Browse files
olsonjefferybrson
authored andcommitted
---
yaml --- r: 12961 b: refs/heads/master c: ffdaf14 h: refs/heads/master i: 12959: 1ccee08 v: v3
1 parent b42f746 commit b65e0a6

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 27427a950aa22b966d28b3e0a3508e0d97f91252
2+
refs/heads/master: ffdaf14dd90995273fd697b9b87018d5dba84379
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libstd/net_tcp.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#[doc="
2+
High-level interface to libuv's TCP functionality
3+
"];
4+
5+
#[cfg(ignore)]
6+
mod test {
7+
#[test]
8+
fn test_gl_tcp_ipv4_request() {
9+
let ip = "127.0.0.1";
10+
let port = 80u;
11+
let expected_read_msg = "foo";
12+
let actual_write_msg = "bar";
13+
let addr = ipv4::address(ip, port);
14+
15+
let data_po = comm::port::<[u8]>();
16+
let data_ch = comm::chan(data_po);
17+
18+
alt connect(addr) {
19+
tcp_connected(tcp_stream) {
20+
let write_data = str::as_buf(actual_write_msg);
21+
alt write(tcp_stream, [write_data]) {
22+
tcp_write_success {
23+
let mut total_read_data: [u8] = []
24+
let reader_po = read_start(tcp_stream);
25+
loop {
26+
alt comm::recv(reader_po) {
27+
new_read_data(data) {
28+
total_read_data += data;
29+
// theoretically, we could keep iterating, here, if
30+
// we expect the server on the other end to keep
31+
// streaming/chunking data to us, but..
32+
read_stop(tcp_stream);
33+
break;
34+
}
35+
done_reading {
36+
break;
37+
}
38+
error {
39+
fail "erroring occured during read attempt.. FIXME need info";
40+
}
41+
}
42+
}
43+
comm::send(data_ch, total_read_data);
44+
}
45+
tcp_write_error {
46+
fail "error during write attempt.. FIXME need err info";
47+
}
48+
}
49+
}
50+
tcp_connect_error {
51+
fail "error during connection attempt.. FIXME need err info..";
52+
}
53+
}
54+
55+
let actual_data = comm::recv(data_po);
56+
let resp = str::from_bytes(actual_data);
57+
log(debug, "DATA RECEIVED: "+resp);
58+
}
59+
}

trunk/src/libstd/std.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export test, tempfile, serialization;
2323
// General io and system-services modules
2424

2525
mod net;
26+
mod net_tcp;
2627

2728
// libuv modules
2829
mod uv;

0 commit comments

Comments
 (0)