about summary refs log tree commit diff
path: root/library/std/src/sys/unix/net.rs
AgeCommit message (Collapse)AuthorLines
2024-01-11std: begin moving platform support modules into `pal`joboet-591/+0
2023-10-19Auto merge of #116132 - darthunix:connect_poll, r=cuviperbors-0/+17
Make TCP connect handle EINTR correctly According to the [POSIX](https://pubs.opengroup.org/onlinepubs/009695399/functions/connect.html) standard, if connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to EINTR, but the connection request shall not be aborted, and the connection shall be established asynchronously. When the connection has been established asynchronously, select() and poll() shall indicate that the file descriptor for the socket is ready for writing. The previous implementation differs from the recomendation: in a case of the EINTR we tried to reconnect in a loop and sometimes get EISCONN error (this problem was originally detected on MacOS). 1. More details about the problem in an [article](http://www.madore.org/~david/computers/connect-intr.html). 2. The original [issue](https://git.picodata.io/picodata/picodata/tarantool-module/-/issues/157).
2023-10-17Updated libc and doc for Vita targetNikolay Arhipov-2/+2
2023-10-13Make TCP connect() handle EINTR correctlyDenis Smirnov-0/+17
According to the POSIX standard, if connect() is interrupted by a signal that is caught while blocked waiting to establish a connection, connect() shall fail and set errno to EINTR, but the connection request shall not be aborted, and the connection shall be established asynchronously. If asynchronous connection was successfully established after EINTR and before the next connection attempt, OS returns EISCONN that was handled as an error before. This behavior is fixed now and we handle it as success. The problem affects MacOS users: Linux doesn't return EISCONN in this case, Windows connect() can not be interrupted without an old-fashoin WSACancelBlockingCall function that is not used in the library. So current solution gives connect() as OS specific implementation.
2023-09-21added support for GNU/HurdSamuel Thibault-0/+3
2023-09-13Disabled socketpair for VitaNikolay Arhipov-2/+2
2023-09-03Use std::io::Error::is_interrupted everywhereBen Kimock-1/+1
2023-06-05Simplified bool to int conversionNikolay Arhipov-4/+1
2023-06-05Std support improvement for ps vita targetNikolay Arhipov-1/+10
2023-05-01Inline AsRawFd implementationsKonrad Borowski-0/+1
2023-05-01Inline AsInner implementationsKonrad Borowski-0/+1
2023-03-27socket ancillary data implementation for FreeBSD (from 13 and above).David CARLIER-0/+11
introducing new build config as well.
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-6/+22
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-0/+2
Co-authored-by: gh-tr <troach@qnx.com>
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-1/+1
2022-08-29Rollup merge of #96334 - devnexen:socket_mark, r=dtolnayMatthias Krüger-0/+11
socket `set_mark` addition. to be able to set a marker/id on the socket for network filtering (iptables/ipfw here) purpose.
2022-08-13created tcpstream quickack traitBerend-Jan Lange-0/+11
for linux and android
2022-07-06changes from feedbackDavid Carlier-12/+8
2022-07-06doc additionsDavid Carlier-0/+5
2022-07-06socket `set_mark` addition.David Carlier-0/+10
to be able to set a marker/id on the socket for network filtering (iptables/ipfw here) purpose.
2022-06-23Represent SocketAddrV4 and SocketAddrV6 as Rust native encodingLinus Färnstrand-2/+2
2022-05-25Disable unix::net::ancillary on BSD.Mara Bos-18/+2
2022-04-04ScmCredentials netbsd implementation.David Carlier-0/+11
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-1/+1
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-7/+7
2021-12-16Revert "socket ancillary data implementation for dragonflybsd."David CARLIER-2/+2
2021-12-05socket ancillary data implementation for dragonflybsd.David Carlier-2/+2
2021-11-12Refactor weak symbols in std::sys::unixJosh Stone-2/+2
This makes a few changes to the weak symbol macros in `sys::unix`: - `dlsym!` is added to keep the functionality for runtime `dlsym` lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't want to show up in ELF symbol tables. - `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime behavior is just a simple null check. This is also used by `syscall!`. - On non-ELF targets (macos/ios) where that linkage is not known to behave, `weak!` is just an alias to `dlsym!` for the old behavior. - `raw_syscall!` is added to always call `libc::syscall` on linux and android, for cases like `clone3` that have no known libc wrapper. The new `weak!` linkage does mean that you'll get versioned symbols if you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`. This might seem problematic, but old non-weak symbols can tie the build to new versions too, like `dlsym@GLIBC_2.34` from their recent library unification. If you build with an old glibc like `dist-x86_64-linux` does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may be resolved based on the runtime glibc. I also found a few functions that don't need to be weak anymore: - Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as these were added in API 12, and our baseline is API 14. - Linux can directly use `splice`, added way back in glibc 2.5 and similarly old musl. Android only added it in API 21 though.
2021-08-30clean up `c::linger` conversionibraheemdev-1/+1
2021-08-30add `TcpStream::set_linger` and `TcpStream::linger`ibraheemdev-0/+23
2021-08-19I/O safety.Dan Gohman-30/+62
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-08-10STD support for the ESP-IDF frameworkivmarkov-2/+8
2021-07-02Auto merge of #85746 - m-ou-se:io-error-other, r=joshtriplettbors-2/+2
Redefine `ErrorKind::Other` and stop using it in std. This implements the idea I shared yesterday in the libs meeting when we were discussing how to handle adding new `ErrorKind`s to the standard library: This redefines `Other` to be for *user defined errors only*, and changes all uses of `Other` in the standard library to a `#[doc(hidden)]` and permanently `#[unstable]` `ErrorKind` that users can not match on. This ensures that adding `ErrorKind`s at a later point in time is not a breaking change, since the user couldn't match on these errors anyway. This way, we use the `#[non_exhaustive]` property of the enum in a more effective way. Open questions: - How do we check this change doesn't cause too much breakage? Will a crate run help and be enough? - How do we ensure we don't accidentally start using `Other` again in the standard library? We don't have a `pub(not crate)` or `#[deprecated(in this crate only)]`. cc https://github.com/rust-lang/rust/pull/79965 cc `@rust-lang/libs` `@ijackson` r? `@dtolnay`
2021-06-15Rename ErrorKind::Unknown to Uncategorized.Mara Bos-2/+2
2021-06-15Redefine `ErrorKind::Other` and stop using it in std.Mara Bos-2/+2
2021-05-26Rename opensbd to openbsdAlbert Ford-3/+3
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-6/+9
2021-02-24Use libc::accept4 on Android instead of raw syscall.Maarten de Vries-7/+1
2020-12-02Auto merge of #69864 - LinkTed:master, r=Amanieubors-0/+39
unix: Extend UnixStream and UnixDatagram to send and receive file descriptors Add the functions `recv_vectored_fds` and `send_vectored_fds` to `UnixDatagram` and `UnixStream`. With this functions `UnixDatagram` and `UnixStream` can send and receive file descriptors, by using `recvmsg` and `sendmsg` system call.
2020-11-06Disable accept4 on Android.Maarten de Vries-1/+7
2020-10-30Use SOCK_CLOEXEC and accept4() on more platforms.Maarten de Vries-6/+32
2020-10-16Take sys/vxworks/net from sys/unix instead.Mara Bos-2/+8
2020-10-10Remove `passcred` for `emscripten`LinkTed-2/+2
2020-10-10Fix `SO_PASSCRED` for macosLinkTed-0/+2
2020-10-10Fix `MSG_CMSG_CLOEXEC` for macosLinkTed-0/+18
2020-10-10Cast boolean into int directly in function set_passcredLinkTed-2/+1
2020-10-10Add `set_passcred` and `passcred` methods to `UnixStream` and `UnixDatagram`LinkTed-0/+10
2020-10-10Move `add_to_ancillary_data` and `AncillaryDataIter` to ancillary.rsLinkTed-82/+0
2020-10-10unix: Extend UnixStream and UnixDatagram to send and receive file descriptorsLinkTed-0/+92
Add the functions `recv_vectored_fds` and `send_vectored_fds` to send and receive file descriptors, by using `recvmsg` and `sendmsg` system call.
2020-07-27mv std libs to library/mark-0/+382