summary refs log tree commit diff
path: root/src/libstd/net
AgeCommit message (Collapse)AuthorLines
2015-07-29Auto merge of #27368 - alexcrichton:deprecate-net-methods, r=aturonbors-0/+24
These methods are all covered by [RFC 1158] and are currently all available on stable Rust via the [`net2` crate][net2] on crates.io. This commit does not touch the timeout related functions as they're still waiting on `Duration` which is unstable anyway, so punting in favor of the `net2` crate wouldn't buy much. [RFC 1158]: https://github.com/rust-lang/rfcs/pull/1158 [net2]: http://crates.io/crates/net2
2015-07-28std: Deprecate extra TcpStream/UdpSocket methodsAlex Crichton-0/+24
These methods are all covered by [RFC 1158] and are currently all available on stable Rust via the [`net2` crate][net2] on crates.io. This commit does not touch the timeout related functions as they're still waiting on `Duration` which is unstable anyway, so punting in favor of the `net2` crate wouldn't buy much. [RFC 1158]: https://github.com/rust-lang/rfcs/pull/1158 [net2]: http://crates.io/crates/net2 Specifically, this commit deprecates: * TcpStream::set_nodelay * TcpStream::set_keepalive * UdpSocket::set_broadcast * UdpSocket::set_multicast_loop * UdpSocket::join_multicast * UdpSocket::set_multicast_time_to_live * UdpSocket::set_time_to_live
2015-07-27Show appropriate feature flags in docsSteve Klabnik-1/+2
2015-07-20std: Add IntoRaw{Fd,Handle,Socket} traitsAlex Crichton-3/+15
This commit is an implementation of [RFC 1174][rfc] which adds three new traits to the standard library: * `IntoRawFd` - implemented on Unix for all I/O types (files, sockets, etc) * `IntoRawHandle` - implemented on Windows for files, processes, etc * `IntoRawSocket` - implemented on Windows for networking types [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1174-into-raw-fd-socket-handle-traits.md Closes #27062
2015-07-19Fix documentation IP ranges: e.g., 192.0.2.* instead of 192.*.2.*.Ken Tossell-4/+8
Add Ipv4Addr tests to verify doc address checking.
2015-07-15Add specializations of read_to_end for Stdin, TcpStream and File,Alisdair Owens-0/+7
allowing them to read into a buffer containing uninitialized data, rather than pay the cost of zeroing.
2015-07-10Change some instances of .connect() to .join()Wesley Wiser-1/+1
2015-07-01Add netbsd amd64 supportAlex Newman-3/+3
2015-06-21Auto merge of #26457 - meqif:master, r=alexcrichtonbors-2/+1
The documentation of `std::net::Shutdown` mentions says it can be passed to the `shutdown` method of `UdpSocket`, which isn't true because `UdpSocket` has no such method. This commit removes that mention.
2015-06-20Remove mention of `UdpSocket` in `Shutdown` docs.Ricardo Martins-2/+1
2015-06-11Auto merge of #26190 - Veedrac:no-iter, r=alexcrichtonbors-1/+1
Pull request for #26188.
2015-06-10Removed many pointless calls to *iter() and iter_mut()Joshua Landau-1/+1
2015-06-10disabling socking timing tests because openbsd/bitrig get/set are not ↵Dave Huseby-0/+6
congruent due to rounding errors
2015-06-07change some statics to constantsOliver 'ker' Schneider-2/+2
2015-05-29Loosen timeout restrictionsSteven Fackler-20/+12
2015-05-29Skip timeout upper bound check on windowsSteven Fackler-4/+12
2015-05-28Implement RFC 1047 - socket timeoutsSteven Fackler-0/+210
Closes #25619
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-2/+2
2015-05-16std: Reexport std::net::tcp::IncomingAlex Crichton-1/+1
This iterator was mistakenly not reexported at the top level, preventing actually naming the type! Closes #25519
2015-05-09Rollup merge of #25216 - barosl:no-more-task, r=ManishearthManish Goregaokar-4/+4
I've found that there are still huge amounts of occurrences of `task`s in the documentation. This PR tries to eliminate all of them in favor of `thread`.
2015-05-09Auto merge of #25212 - pnkfelix:dropck-box-trait, r=nikomatsakisbors-1/+1
dropck: must assume `Box<Trait + 'a>` has a destructor of interest. Fix #25199. This detail was documented in [RFC 769]; the implementation was just missing. [breaking-change] The breakage here falls into both obvious and non-obvious cases. The obvious case: if you were relying on the unsoundness this exposes (namely being able to reference dead storage from a destructor, by doing it via a boxed trait object bounded by the lifetime of the dead storage), then this change disallows that. The non-obvious cases: The way dropck works, it causes lifetimes to be extended to longer extents than they covered before. I.e. lifetimes that are attached as trait-bounds may become longer than they were previously. * This includes lifetimes that are only *implicitly* attached as trait-bounds (due to [RFC 599]). So you may have code that was e.g. taking a parameter of type `&'a Box<Trait>` (which expands to `&'a Box<Trait+'a>`), that now may need to be assigned type `&'a Box<Trait+'static>` to ensure that `'a` is not inadvertantly inferred to a region that is actually too long. (See commit ee06263 for an example of this.) [RFC 769]: https://github.com/rust-lang/rfcs/blob/master/text/0769-sound-generic-drop.md#the-drop-check-rule [RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-4/+4
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-05-08Fallout from fixing Issue 25199.Felix S. Klock II-1/+1
There are two interesting kinds of breakage illustrated here: 1. `Box<Trait>` in many contexts is treated as `Box<Trait + 'static>`, due to [RFC 599]. However, in a type like `&'a Box<Trait>`, the `Box<Trait>` type will be expanded to `Box<Trait + 'a>`, again due to [RFC 599]. This, combined with the fix to Issue 25199, leads to a borrowck problem due the combination of this function signature (in src/libstd/net/parser.rs): ```rust fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T>>]) -> Option<T>; ``` with this call site (again in src/libstd/net/parser.rs): ```rust fn read_ip_addr(&mut self) -> Option<IpAddr> { let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(|v4| IpAddr::V4(v4)); let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(|v6| IpAddr::V6(v6)); self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) } ``` yielding borrowck errors like: ``` parser.rs:265:27: 265:69 error: borrowed value does not live long enough parser.rs:265 self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` (full log at: https://gist.github.com/pnkfelix/e2e80f1a71580f5d3103 ) The issue here is perhaps subtle: the `parsers` argument is inferred to be taking a slice of boxed objects with the implicit lifetime bound attached to the `self` parameter to `read_or`. Meanwhile, the fix to Issue 25199 (added in a forth-coming commit) is forcing us to assume that each boxed object may have a destructor that could refer to state of that lifetime, and *therefore* that inferred lifetime is required to outlive the boxed object itself. In this case, the relevant boxed object here is not going to make any such references; I believe it is just an artifact of how the expression was built that it is not assigned type: `Box<FnMut(&mut Parser) -> Option<T> + 'static>`. (i.e., mucking with the expression is probably one way to fix this problem). But the other way to fix it, adopted here, is to change the `read_or` method type to force make the (presumably-intended) `'static` bound explicit on the boxed `FnMut` object. (Note: this is still just the *first* example of breakage.) 2. In `macro_rules.rs`, the `TTMacroExpander` trait defines a method with signature: ```rust fn expand<'cx>(&self, cx: &'cx mut ExtCtxt, ...) -> Box<MacResult+'cx>; ``` taking a `&'cx mut ExtCtxt` as an argument and returning a `Box<MacResult'cx>`. The fix to Issue 25199 (added in aforementioned forth-coming commit) assumes that a value of type `Box<MacResult+'cx>` may, in its destructor, refer to a reference of lifetime `'cx`; thus the `'cx` lifetime is forced to outlive the returned value. Meanwhile, within `expand.rs`, the old code was doing: ```rust match expander.expand(fld.cx, ...).make_pat() { ... => immutable borrow of fld.cx ... } ``` The problem is that the `'cx` lifetime, inferred for the `expander.expand` call, has now been extended so that it has to outlive the temporary R-value returned by `expanded.expand`. But call is also reborrowing `fld.cx` *mutably*, which means that this reborrow must end before any immutable borrow of `fld.cx`; but there is one of those within the match body. (Note that the temporary R-values for the input expression to `match` all live as long as the whole `match` expression itself (see Issue #3511 and PR #11585). To address this, I moved the construction of the pat value into its own `let`-statement, so that the `Box<MacResult>` will only live for as long as the initializing expression for the `let`-statement, and thus allow the subsequent immutable borrow within the `match`. [RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
2015-05-07std: Rename sys::foo2 modules to sys::fooAlex Crichton-3/+3
Now that `std::old_io` has been removed for quite some time the naming real estate here has opened up to allow these modules to move back to their proper names.
2015-05-05Rollup merge of #25105 - tshepang:doc-addr, r=steveklabnikManish Goregaokar-1/+2
This did not render as intended: >This is defined in RFC 5737 - 192.0.2.0/24 (TEST-NET-1) - 198.51.100.0/24 (TEST-NET-2) - 203.0.113.0/24 (TEST-NET-3) vs. > This is defined in RFC 5737 - 192.0.2.0/24 (TEST-NET-1) - 198.51.100.0/24 (TEST-NET-2) - 203.0.113.0/24 (TEST-NET-3)
2015-05-04Auto merge of #24652 - achanda:ip-long, r=alexcrichtonbors-1/+27
2015-05-04doc: fix markupTshepang Lekhonkhobe-1/+2
2015-05-04Auto merge of #25078 - nham:std_net_impl_debug, r=alexcrichtonbors-1/+58
I'm uncertain whether the 3 implementations in `net2` should unwrap the socket address values. Without unwrapping it looks like this: ``` UdpSocket { addr: Ok(V4(127.0.0.1:34354)), inner: 3 } TcpListener { addr: Ok(V4(127.0.0.1:9123)), inner: 4 } TcpStream { addr: Ok(V4(127.0.0.1:9123)), peer: Ok(V4(127.0.0.1:58360)), inner: 5 } ``` One issue is that you can create, e.g. `UdpSocket`s with bad addresses, which means you can't just unwrap in the implementation: ``` #![feature(from_raw_os)] use std::net::UdpSocket; use std::os::unix::io::FromRawFd; let sock: UdpSocket = unsafe { FromRawFd::from_raw_fd(-1) }; println!("{:?}", sock); // prints "UdpSocket { addr: Err(Error { repr: Os(9) }), inner: -1 }" ``` Fixes #23134.
2015-05-04Auto merge of #25044 - tshepang:doc-addr, r=alexcrichtonbors-10/+18
2015-05-03Add functions to convert IPv4 to long and backAbhishek Chanda-1/+27
2015-05-03Add tests for 3 Debug implementationsNick Hamann-0/+37
2015-05-03Implement Debug for std::net::{UdpSocket,TcpStream,TcpListener,Shutdown}Nick Hamann-1/+21
Fixes #23134.
2015-05-03doc: improve IpAddr is_global and is_unicast_globalTshepang Lekhonkhobe-10/+18
2015-05-01std: Remove index notation on slice iteratorsAlex Crichton-1/+1
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791
2015-04-29rollup merge of #24961: nham/net_docs_cleanupAlex Crichton-39/+39
Changes made include adding missing punctuation, adding missing words, and converting uses of "Gets" to "Returns" in libstd/net/addr.rs to make it more consistent with the other documentation. Fixes #24925.
2015-04-29Improve libstd/net/addr.rs documentation.Nick Hamann-9/+9
This adds some missing punctuation and converts uses of "Gets" to "Returns". This sounds better to my ear, but more importantly is more consistent with the documentation from other files.
2015-04-29Add some missing punctuation in the libstd/net/tcp.rs docs.Nick Hamann-1/+1
2015-04-29Add some missing punctuation in the libstd/net/ip.rs docs.Nick Hamann-19/+19
2015-04-29Improve libstd/net/udp.rs documentation.Nick Hamann-10/+10
This adds some missing punctuation, adds a missing word, and corrects a bug in the description of `send_to`, which actually returns the number of bytes written on success. Fixes #24925.
2015-04-28remove stability note from std::netSteve Klabnik-4/+1
This is served by stability markers.
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-6/+15
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-15Rollup merge of #24480 - achanda:move_test, r=alexcrichtonSteve Klabnik-259/+270
- Also move common functions to test.rs - Leaves out Socket address related tests in addr.rs
2015-04-15Move IP related tests to ip.rsAbhishek Chanda-259/+270
- Also move common functions to test.rs - Leaves out Socket address related tests in addr.rs
2015-04-15Fix some typos.Ms2ger-1/+1
2015-04-14rollup merge of #24377: apasel422/docsAlex Crichton-12/+12
Conflicts: src/libstd/net/ip.rs src/libstd/sys/unix/fs.rs src/libstd/sys/unix/mod.rs src/libstd/sys/windows/mod.rs
2015-04-13Fix check for globally routable IPv4 addressAbhishek Chanda-15/+43
- Adds two more functions for broadcast address and special address classes reserved for documentation - Modifies the globally routable IP check to include these new functions Fixes #24314
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-12/+12
2015-04-10Auto merge of #24177 - alexcrichton:rustdoc, r=aturonbors-5/+1
This commit series starts out with more official test harness support for rustdoc tests, and then each commit afterwards adds a test (where appropriate). Each commit should also test and finish independently of all others (they're all pretty separable). I've uploaded a [copy of the documentation](http://people.mozilla.org/~acrichton/doc/std/) generated after all these commits were applied, and a double check on issues being closed would be greatly appreciated! I'll also browse the docs a bit and make sure nothing regressed too horribly.
2015-04-07std: Deny most warnings in doctestsAlex Crichton-5/+1
Allow a few specific ones but otherwise this helps ensure that our examples are squeaky clean! Closes #18199
2015-04-07disabling a test that is failing on bitrig.Dave Huseby-1/+2