about summary refs log tree commit diff
path: root/src/libstd/net_tcp.rs
diff options
context:
space:
mode:
authorJeff Olson <olson.jeffery@gmail.com>2012-06-17 20:36:36 -0700
committerBrian Anderson <banderson@mozilla.com>2012-06-29 15:41:55 -0700
commit30f26ddbc99e34c42f110625f66fc9399d6f38d1 (patch)
treeaf5f27465b1bd3d5c3913e17fd78e16ac6252a5a /src/libstd/net_tcp.rs
parentc0272928464c9f3ec8aa2e4a7ed17de6157ad59b (diff)
downloadrust-30f26ddbc99e34c42f110625f66fc9399d6f38d1.tar.gz
rust-30f26ddbc99e34c42f110625f66fc9399d6f38d1.zip
std: adding uv::ll::ip4_name and refactored net::ip to use it
replaces net::ip's previously, hand-rolled impl for ipv4 addr parsing..
we're relying on libuv, now
Diffstat (limited to 'src/libstd/net_tcp.rs')
-rw-r--r--src/libstd/net_tcp.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs
index 6718e3729f7..7c3349efae4 100644
--- a/src/libstd/net_tcp.rs
+++ b/src/libstd/net_tcp.rs
@@ -126,7 +126,7 @@ that can be used to send and receive data to/from the remote host. In the
 event of failure, a `net::tcp::tcp_connect_err_data` instance will be
 returned
 "]
-fn connect(input_ip: ip::ip_addr, port: uint,
+fn connect(-input_ip: ip::ip_addr, port: uint,
            iotask: iotask)
     -> result::result<tcp_socket, tcp_connect_err_data> unsafe {
     let result_po = comm::port::<conn_attempt>();
@@ -551,7 +551,7 @@ a `result` instance containing empty data of type `()` on a
 successful/normal shutdown, and a `tcp_listen_err_data` enum in the event
 of listen exiting because of an error
 "]
-fn listen(host_ip: ip::ip_addr, port: uint, backlog: uint,
+fn listen(-host_ip: ip::ip_addr, port: uint, backlog: uint,
           iotask: iotask,
           on_establish_cb: fn~(comm::chan<option<tcp_err_data>>),
           +new_connect_cb: fn~(tcp_new_connection,
@@ -568,7 +568,7 @@ fn listen(host_ip: ip::ip_addr, port: uint, backlog: uint,
     }
 }
 
-fn listen_common(host_ip: ip::ip_addr, port: uint, backlog: uint,
+fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
           iotask: iotask,
           on_establish_cb: fn~(comm::chan<option<tcp_err_data>>),
           -on_connect_cb: fn~(*uv::ll::uv_tcp_t))
@@ -589,8 +589,15 @@ fn listen_common(host_ip: ip::ip_addr, port: uint, backlog: uint,
     let server_data_ptr = ptr::addr_of(server_data);
 
     let setup_result = comm::listen {|setup_ch|
+        // FIXME this is to address a compiler warning about
+        // an implicit copy.. it seems that double nested
+        // will defeat a move sigil, as is done to the host_ip
+        // arg above.. this same pattern works w/o complaint in
+        // tcp::connect (because the iotask::interact cb isn't
+        // nested within a comm::listen block)
+        let loc_ip = copy(host_ip);
         iotask::interact(iotask) {|loop_ptr|
-            let tcp_addr = ipv4_ip_addr_to_sockaddr_in(host_ip,
+            let tcp_addr = ipv4_ip_addr_to_sockaddr_in(loc_ip,
                                                        port);
             alt uv::ll::tcp_init(loop_ptr, server_stream_ptr) {
               0i32 {
@@ -1201,9 +1208,10 @@ type tcp_buffered_socket_data = {
 fn ipv4_ip_addr_to_sockaddr_in(input_ip: ip::ip_addr,
                                port: uint) -> uv::ll::sockaddr_in unsafe {
     // FIXME (#2656): ipv6
+    let addr_str = ip::format_addr(input_ip);
     alt input_ip {
-      ip::ipv4(_,_,_,_) {
-        uv::ll::ip4_addr(ip::format_addr(input_ip), port as int)
+      ip::ipv4(addr) {
+        uv::ll::ip4_addr(addr_str, port as int)
       }
       ip::ipv6(_,_,_,_,_,_,_,_) {
         fail "FIXME (#2656) ipv6 not yet supported";