about summary refs log tree commit diff
path: root/library/std/src/net/udp.rs
AgeCommit message (Collapse)AuthorLines
2025-09-08std: make address resolution weirdness local to SGXjoboet-2/+2
2025-03-10Disable unsupported testsNicole LeGare-1/+2
Unclear why this needs to be done manually and is not done by the existing Trusty patches.
2025-02-02std: move network code into `sys`joboet-1/+2
As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules. I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2024-11-26std: update internal uses of `io::const_error!`joboet-3/+1
2024-09-30Rollup merge of #129638 - nickrum:wasip2-net, r=alexcrichtonTrevor Gross-1/+9
Hook up std::net to wasi-libc on wasm32-wasip2 target One of the improvements of the `wasm32-wasip2` target over `wasm32-wasip1` is better support for networking. Right now, p2 is just re-using the `std::net` implementation from p1. This PR adds a new net module for p2 that makes use of net from `sys_common` and calls wasi-libc functions directly. There are currently a few limitations: - Duplicating a socket is not supported by WASIp2 (directly returns an error) - Peeking is not yet implemented in wasi-libc (we could let wasi-libc handle this, but I opted to directly return an error instead) - Vectored reads/writes are not supported by WASIp2 (the necessary functions are available in wasi-libc, but they call WASIp1 functions which do not support sockets, so I opted to directly return an error instead) - Getting/setting `TCP_NODELAY` is faked in wasi-libc (uses the fake implementation instead of returning an error) - Getting/setting `SO_LINGER` is not supported by WASIp2 (directly returns an error) - Setting `SO_REUSEADDR` is faked in wasi-libc (since this is done from `sys_common`, the fake implementation is used instead of returning an error) - Getting/setting `IPV6_V6ONLY` is not supported by WASIp2 and will always be set for IPv6 sockets (since this is done from `sys_common`, wasi-libc will return an error) - UDP broadcast/multicast is not supported by WASIp2 (since this is configured from `sys_common`, wasi-libc will return appropriate errors) - The `MSG_NOSIGNAL` send flag is a no-op because there are no signals in WASIp2 (since explicitly setting this flag would require a change to `sys_common` and the result would be exactly the same, I opted to not set it) Do those decisions make sense? While working on this PR, I noticed that there is a `std::os::wasi::net::TcpListenerExt` trait that adds a `sock_accept()` method to `std::net::TcpListener`. Now that WASIp2 supports standard accept, would it make sense to remove this? cc `@alexcrichton`
2024-09-29Rollup merge of #130743 - YohDeadfall:net-nonblocking-doc, r=Mark-SimulacrumGuillaume Gomez-1/+1
Clarifications for set_nonblocking methods Closes #129903. The issue mentions that `send`, `recv` and other operations are interpreted by some users as methods of `TcpSocket` which led to confusion since it hasn't them. To fix it I added "system" into the documentation as being more precise for two reasons: * it's makes it clear that these names are system operations; * it doesn't point to the location of these methods like `libc` because not every system is POSIX compatible.
2024-09-29Fix std tests for wasm32-wasip2 targetNicola Krumschmidt-1/+9
2024-09-27Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4Asger Hautop Drewsen-2/+2
2024-09-23Clarifications for set_nonblocking methodsYoh Deadfall-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2023-10-03Auto merge of #105394 - Patiga:improve-udpsocket-docs, r=workingjubileebors-1/+20
Improve UdpSocket documentation I tried working with `UdpSocket` and ran into `EINVAL` errors with no clear indication of what causes the error. Also, it was uncharacteristically hard to figure this module out, compared to other Rust `std` modules. 1. `send` and `send_to` return a `usize` This one is just clarity. Usually, returned `usize`s indicate that the buffer might have only been sent partially. This is not the case with UDP. Since that `usize` must always be `buffer.len()`, I have documented that. 2. `bind` limits `connect` and `send_to` When you bind to a limited address space like localhost, you can only `connect` to addresses in that same address space. Error kind: `AddrNotAvailable`. 3. `connect`ing to localhost locks you to localhost On Linux, if you first `connect` to localhost, subsequent `connect`s to non-localhost addresses fail. Error kind: `InvalidInput`. For debugging the third one, it was really hard to find someone else who already had that problem. I only managed to find this thread: https://www.mail-archive.com/netdev@vger.kernel.org/msg159519.html
2023-08-22Improve UdpSocket documentationPatiga-1/+20
I tried working with `UdpSocket` and ran into `EINVAL` errors with no clear indication of what causes the error. Also, it was uncharacteristically hard to figure this module out, compared to other Rust `std` modules. 1. `send` and `send_to` return a `usize` This one is just clarity. Usually, returned `usize`s indicate that the buffer might have only been sent partially. This is not the case with UDP. Since that `usize` must always be `buffer.len()`, I have documented that. 2. `bind` limits `connect` and `send_to` When you bind to a limited address space like localhost, you can only `connect` to addresses in that same address space. Error kind: `AddrNotAvailable`. 3. `connect`ing to localhost locks you to localhost On Linux, if you first `connect` to localhost, subsequent `connect`s to non-localhost addresses fail. Error kind: `InvalidInput`. Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2023-08-22std: net: skip tests on xousSean Cross-1/+1
Network functionality is not yet ready for merging. Signed-off-by: Sean Cross <sean@xobs.io>
2023-05-13add examples of port 0 binding behaviorkirk-0/+9
2023-05-01Inline AsInner implementationsKonrad Borowski-0/+1
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-7/+7
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-2/+4
2021-08-30Remove unnecessary `mut` from udp doctestsSönke Hahn-1/+1
2021-08-19Add comments about impls for File, TcpStream, ChildStdin, etc.Dan Gohman-0/+6
2021-07-29Fix may not to appropriate might not or must notAli Malik-3/+3
2021-05-02Add link to Issue #34202 in udp docswcampbell-1/+3
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-1/+1
2020-11-22Drop support for cloudabi targetsLzu Tao-1/+1
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-377/+3
Also doing fmt inplace as requested.
2020-08-15Move to intra doc links in std::netAlexis Bourget-67/+27
2020-07-27mv std libs to library/mark-0/+1217