Files
google-apis-rs/socket2/struct.Socket.html
2024-03-05 21:06:01 +01:00

917 lines
267 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Owned wrapper around a system socket."><title>Socket in socket2 - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="socket2" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../socket2/index.html">socket2</a><span class="version">0.5.5</span></h2></div><h2 class="location"><a href="#">Socket</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.accept">accept</a></li><li><a href="#method.accept_raw">accept_raw</a></li><li><a href="#method.bind">bind</a></li><li><a href="#method.bind_device_by_index">bind_device_by_index</a></li><li><a href="#method.bind_device_by_index_v4">bind_device_by_index_v4</a></li><li><a href="#method.bind_device_by_index_v6">bind_device_by_index_v6</a></li><li><a href="#method.broadcast">broadcast</a></li><li><a href="#method.connect">connect</a></li><li><a href="#method.connect_timeout">connect_timeout</a></li><li><a href="#method.device_index">device_index</a></li><li><a href="#method.device_index_v4">device_index_v4</a></li><li><a href="#method.device_index_v6">device_index_v6</a></li><li><a href="#method.header_included">header_included</a></li><li><a href="#method.join_multicast_v4">join_multicast_v4</a></li><li><a href="#method.join_multicast_v4_n">join_multicast_v4_n</a></li><li><a href="#method.join_multicast_v6">join_multicast_v6</a></li><li><a href="#method.join_ssm_v4">join_ssm_v4</a></li><li><a href="#method.keepalive">keepalive</a></li><li><a href="#method.keepalive_interval">keepalive_interval</a></li><li><a href="#method.keepalive_retries">keepalive_retries</a></li><li><a href="#method.keepalive_time">keepalive_time</a></li><li><a href="#method.leave_multicast_v4">leave_multicast_v4</a></li><li><a href="#method.leave_multicast_v4_n">leave_multicast_v4_n</a></li><li><a href="#method.leave_multicast_v6">leave_multicast_v6</a></li><li><a href="#method.leave_ssm_v4">leave_ssm_v4</a></li><li><a href="#method.linger">linger</a></li><li><a href="#method.listen">listen</a></li><li><a href="#method.local_addr">local_addr</a></li><li><a href="#method.mss">mss</a></li><li><a href="#method.multicast_hops_v6">multicast_hops_v6</a></li><li><a href="#method.multicast_if_v4">multicast_if_v4</a></li><li><a href="#method.multicast_if_v6">multicast_if_v6</a></li><li><a href="#method.multicast_loop_v4">multicast_loop_v4</a></li><li><a href="#method.multicast_loop_v6">multicast_loop_v6</a></li><li><a href="#method.multicast_ttl_v4">multicast_ttl_v4</a></li><li><a href="#method.new">new</a></li><li><a href="#method.new_raw">new_raw</a></li><li><a href="#method.nodelay">nodelay</a></li><li><a href="#method.nonblocking">nonblocking</a></li><li><a href="#method.only_v6">only_v6</a></li><li><a href="#method.out_of_band_inline">out_of_band_inline</a></li><li><a href="#method.pair">pair</a></li><li><a href="#method.pair_raw">pair_raw</a></li><li><a href="#method.peek">peek</a></li><li><a href="#method.peek_from">peek_from</a></li><li><a href="#method.peek_sender">peek_sender</a></li><li><a href="#method.peer_addr">peer_addr</a></li><li><a href="#method.read_timeout">read_timeout</a></li><li><a href="#method.recv">recv</a></li><li><a href="#method.recv_buffer_size">recv_buffer_size</a></li><li><a href="#method.recv_from">recv_from</a></li><li><a href="#method.recv_from_vectored">recv_from_vectored</a></li><li><a href="#method.recv_from_vectored_with_flags">recv_from_vectored_with_flags</a></li><li><a href="#method.recv_from_with_flags">recv_from_with_flags</a></li><li><a href="#method.recv_out_of_band">recv_out_of_band</a></li><li><a href="#method.recv_tclass_v6">recv_tclass_v6</a></li><li><a href="#method.recv_tos">recv_tos</a></li><li><a href="#method.recv_vectored">recv_vectored</a></li><li><a href="#method.recv_vectored_with_flags">recv_vectored_with_flags</a></li><li><a href="#method.recv_with_flags">recv_with_flags</a></li><li><a href="#method.recvmsg">recvmsg</a></li><li><a href="#method.reuse_address">reuse_address</a></li><li><a href="#method.reuse_port">reuse_port</a></li><li><a href="#method.send">send</a></li><li><a href="#method.send_buffer_size">send_buffer_size</a></li><li><a href="#method.send_out_of_band">send_out_of_band</a></li><li><a href="#method.send_to">send_to</a></li><li><a href="#method.send_to_vectored">send_to_vectored</a></li><li><a href="#method.send_to_vectored_with_flags">send_to_vectored_with_flags</a></li><li><a href="#method.send_to_with_flags">send_to_with_flags</a></li><li><a href="#method.send_vectored">send_vectored</a></li><li><a href="#method.send_vectored_with_flags">send_vectored_with_flags</a></li><li><a href="#method.send_with_flags">send_with_flags</a></li><li><a href="#method.sendfile">sendfile</a></li><li><a href="#method.sendmsg">sendmsg</a></li><li><a href="#method.set_broadcast">set_broadcast</a></li><li><a href="#method.set_cloexec">set_cloexec</a></li><li><a href="#method.set_header_included">set_header_included</a></li><li><a href="#method.set_keepalive">set_keepalive</a></li><li><a href="#method.set_linger">set_linger</a></li><li><a href="#method.set_mss">set_mss</a></li><li><a href="#method.set_multicast_hops_v6">set_multicast_hops_v6</a></li><li><a href="#method.set_multicast_if_v4">set_multicast_if_v4</a></li><li><a href="#method.set_multicast_if_v6">set_multicast_if_v6</a></li><li><a href="#method.set_multicast_loop_v4">set_multicast_loop_v4</a></li><li><a href="#method.set_multicast_loop_v6">set_multicast_loop_v6</a></li><li><a href="#method.set_multicast_ttl_v4">set_multicast_ttl_v4</a></li><li><a href="#method.set_nodelay">set_nodelay</a></li><li><a href="#method.set_nonblocking">set_nonblocking</a></li><li><a href="#method.set_nosigpipe">set_nosigpipe</a></li><li><a href="#method.set_only_v6">set_only_v6</a></li><li><a href="#method.set_out_of_band_inline">set_out_of_band_inline</a></li><li><a href="#method.set_read_timeout">set_read_timeout</a></li><li><a href="#method.set_recv_buffer_size">set_recv_buffer_size</a></li><li><a href="#method.set_recv_tclass_v6">set_recv_tclass_v6</a></li><li><a href="#method.set_recv_tos">set_recv_tos</a></li><li><a href="#method.set_reuse_address">set_reuse_address</a></li><li><a href="#method.set_reuse_port">set_reuse_port</a></li><li><a href="#method.set_send_buffer_size">set_send_buffer_size</a></li><li><a href="#method.set_tclass_v6">set_tclass_v6</a></li><li><a href="#method.set_tcp_keepalive">set_tcp_keepalive</a></li><li><a href="#method.set_tos">set_tos</a></li><li><a href="#method.set_ttl">set_ttl</a></li><li><a href="#method.set_unicast_hops_v6">set_unicast_hops_v6</a></li><li><a href="#method.set_write_timeout">set_write_timeout</a></li><li><a href="#method.shutdown">shutdown</a></li><li><a href="#method.take_error">take_error</a></li><li><a href="#method.tclass_v6">tclass_v6</a></li><li><a href="#method.tos">tos</a></li><li><a href="#method.try_clone">try_clone</a></li><li><a href="#method.ttl">ttl</a></li><li><a href="#method.type">type</a></li><li><a href="#method.unicast_hops_v6">unicast_hops_v6</a></li><li><a href="#method.write_timeout">write_timeout</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-AsFd-for-Socket">AsFd</a></li><li><a href="#impl-AsRawFd-for-Socket">AsRawFd</a></li><li><a href="#impl-Debug-for-Socket">Debug</a></li><li><a href="#impl-From%3COwnedFd%3E-for-Socket">From&lt;OwnedFd&gt;</a></li><li><a href="#impl-From%3CSocket%3E-for-OwnedFd">From&lt;Socket&gt;</a></li><li><a href="#impl-From%3CSocket%3E-for-TcpListener">From&lt;Socket&gt;</a></li><li><a href="#impl-From%3CSocket%3E-for-TcpStream">From&lt;Socket&gt;</a></li><li><a href="#impl-From%3CSocket%3E-for-UdpSocket">From&lt;Socket&gt;</a></li><li><a href="#impl-From%3CSocket%3E-for-UnixDatagram">From&lt;Socket&gt;</a></li><li><a href="#impl-From%3CSocket%3E-for-UnixListener">From&lt;Socket&gt;</a></li><li><a href="#impl-From%3CSocket%3E-for-UnixStream">From&lt;Socket&gt;</a></li><li><a href="#impl-From%3CTcpListener%3E-for-Socket">From&lt;TcpListener&gt;</a></li><li><a href="#impl-From%3CTcpStream%3E-for-Socket">From&lt;TcpStream&gt;</a></li><li><a href="#impl-From%3CUdpSocket%3E-for-Socket">From&lt;UdpSocket&gt;</a></li><li><a href="#impl-From%3CUnixDatagram%3E-for-Socket">From&lt;UnixDatagram&gt;</a></li><li><a href="#impl-From%3CUnixListener%3E-for-Socket">From&lt;UnixListener&gt;</a></li><li><a href="#impl-From%3CUnixStream%3E-for-Socket">From&lt;UnixStream&gt;</a></li><li><a href="#impl-FromRawFd-for-Socket">FromRawFd</a></li><li><a href="#impl-IntoRawFd-for-Socket">IntoRawFd</a></li><li><a href="#impl-Read-for-%26Socket">Read</a></li><li><a href="#impl-Read-for-Socket">Read</a></li><li><a href="#impl-Write-for-%26Socket">Write</a></li><li><a href="#impl-Write-for-Socket">Write</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-Socket">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Socket">Send</a></li><li><a href="#impl-Sync-for-Socket">Sync</a></li><li><a href="#impl-Unpin-for-Socket">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Socket">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-T">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-T">Into&lt;U&gt;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In crate socket2</a></h2></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../socket2/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="index.html">socket2</a>::<wbr><a class="struct" href="#">Socket</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/socket2/socket.rs.html#75-77">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub struct Socket { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Owned wrapper around a system socket.</p>
<p>This type simply wraps an instance of a file descriptor (<code>c_int</code>) on Unix
and an instance of <code>SOCKET</code> on Windows. This is the main type exported by
this crate and is intended to mirror the raw semantics of sockets on
platforms as closely as possible. Almost all methods correspond to
precisely one libc or OS API call which is essentially just a “Rustic
translation” of whats below.</p>
<h3 id="converting-to-and-from-other-types"><a href="#converting-to-and-from-other-types">Converting to and from other types</a></h3>
<p>This type can be freely converted into the network primitives provided by
the standard library, such as <a href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream"><code>TcpStream</code></a> or <a href="https://doc.rust-lang.org/1.76.0/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket"><code>UdpSocket</code></a>, using the
<a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From"><code>From</code></a> trait, see the example below.</p>
<h2 id="notes"><a href="#notes">Notes</a></h2>
<p>Some methods that set options on <code>Socket</code> require two system calls to set
their options without overwriting previously set options. We do this by
first getting the current settings, applying the desired changes, and then
updating the settings. This means that the operation is <strong>not</strong> atomic. This
can lead to a data race when two threads are changing options in parallel.</p>
<h2 id="examples"><a href="#examples">Examples</a></h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::net::{SocketAddr, TcpListener};
<span class="kw">use </span>socket2::{Socket, Domain, Type};
<span class="comment">// create a TCP listener
</span><span class="kw">let </span>socket = Socket::new(Domain::IPV6, Type::STREAM, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>address: SocketAddr = <span class="string">"[::1]:12345"</span>.parse().unwrap();
<span class="kw">let </span>address = address.into();
socket.bind(<span class="kw-2">&amp;</span>address)<span class="question-mark">?</span>;
socket.listen(<span class="number">128</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>listener: TcpListener = socket.into();
<span class="comment">// ...</span></code></pre></div>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#82-751">source</a><a href="#impl-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#131-134">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
protocol: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>&gt;
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt;</h4></section></summary><div class="docblock"><p>Creates a new socket and sets common flags.</p>
<p>This function corresponds to <code>socket(2)</code> on Unix and <code>WSASocketW</code> on
Windows.</p>
<p>On Unix-like systems, the close-on-exec flag is set on the new socket.
Additionally, on Apple platforms <code>SOCK_NOSIGPIPE</code> is set. On Windows,
the socket is made non-inheritable.</p>
<p><a href="struct.Socket.html#method.new_raw" title="associated function socket2::Socket::new_raw"><code>Socket::new_raw</code></a> can be used if you dont want these flags to be set.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=socket&amp;section=2">https://man.dragonflybsd.org/?command=socket&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=socket&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=socket&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/socket.2.html">https://man7.org/linux/man-pages/man2/socket.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/socket.2">https://man.netbsd.org/socket.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/socket.2">https://man.openbsd.org/socket.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/socket">https://illumos.org/man/3SOCKET/socket</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.new_raw" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#140-143">source</a><h4 class="code-header">pub fn <a href="#method.new_raw" class="fn">new_raw</a>(
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
protocol: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>&gt;
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt;</h4></section></summary><div class="docblock"><p>Creates a new socket ready to be configured.</p>
<p>This function corresponds to <code>socket(2)</code> on Unix and <code>WSASocketW</code> on
Windows and simply creates a new socket, no other configuration is done.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.pair" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#154-164">source</a><h4 class="code-header">pub fn <a href="#method.pair" class="fn">pair</a>(
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
protocol: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>&gt;
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>)&gt;</h4></section></summary><div class="docblock"><p>Creates a pair of sockets which are connected to each other.</p>
<p>This function corresponds to <code>socketpair(2)</code>.</p>
<p>This function sets the same flags as in done for <a href="struct.Socket.html#method.new" title="associated function socket2::Socket::new"><code>Socket::new</code></a>,
<a href="struct.Socket.html#method.pair_raw" title="associated function socket2::Socket::pair_raw"><code>Socket::pair_raw</code></a> can be used if you dont want to set those flags.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=socketpair&amp;section=2">https://man.dragonflybsd.org/?command=socketpair&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=socketpair&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=socketpair&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/socketpair.2.html">https://man7.org/linux/man-pages/man2/socketpair.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/socketpair.2">https://man.netbsd.org/socketpair.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/socketpair.2">https://man.openbsd.org/socketpair.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/socketpair">https://illumos.org/man/3SOCKET/socketpair</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.pair_raw" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#171-179">source</a><h4 class="code-header">pub fn <a href="#method.pair_raw" class="fn">pair_raw</a>(
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
protocol: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>&gt;
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>)&gt;</h4></section></summary><div class="docblock"><p>Creates a pair of sockets which are connected to each other.</p>
<p>This function corresponds to <code>socketpair(2)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#186-188">source</a><h4 class="code-header">pub fn <a href="#method.bind" class="fn">bind</a>(&amp;self, address: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Binds this socket to the specified address.</p>
<p>This function directly corresponds to the <code>bind(2)</code> function on Windows
and Unix.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=bind&amp;section=2">https://man.dragonflybsd.org/?command=bind&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=bind&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=bind&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/bind.2.html">https://man7.org/linux/man-pages/man2/bind.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/bind.2">https://man.netbsd.org/bind.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/bind.2">https://man.openbsd.org/bind.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/bind">https://illumos.org/man/3SOCKET/bind</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.connect" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#205-207">source</a><h4 class="code-header">pub fn <a href="#method.connect" class="fn">connect</a>(&amp;self, address: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Initiate a connection on this socket to the specified address.</p>
<p>This function directly corresponds to the <code>connect(2)</code> function on
Windows and Unix.</p>
<p>An error will be returned if <code>listen</code> or <code>connect</code> has already been
called on this builder.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=connect&amp;section=2">https://man.dragonflybsd.org/?command=connect&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=connect&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=connect&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/connect.2.html">https://man7.org/linux/man-pages/man2/connect.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/connect.2">https://man.netbsd.org/connect.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/connect.2">https://man.openbsd.org/connect.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/connect">https://illumos.org/man/3SOCKET/connect</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect</a></li>
</ul>
<h5 id="notes-1"><a href="#notes-1">Notes</a></h5>
<p>When using a non-blocking connect (by setting the socket into
non-blocking mode before calling this function), socket option cant be
set <em>while connecting</em>. This will cause errors on Windows. Socket
options can be safely set before and after connecting the socket.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.connect_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#228-242">source</a><h4 class="code-header">pub fn <a href="#method.connect_timeout" class="fn">connect_timeout</a>(&amp;self, addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>, timeout: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Initiate a connection on this socket to the specified address, only
only waiting for a certain period of time for the connection to be
established.</p>
<p>Unlike many other methods on <code>Socket</code>, this does <em>not</em> correspond to a
single C function. It sets the socket to nonblocking mode, connects via
connect(2), and then waits for the connection to complete with poll(2)
on Unix and select on Windows. When the connection is complete, the
socket is set back to blocking mode. On Unix, this will loop over
<code>EINTR</code> errors.</p>
<h5 id="warnings"><a href="#warnings">Warnings</a></h5>
<p>The non-blocking state of the socket is overridden by this function -
it will be returned in blocking mode on success, and in an indeterminate
state on failure.</p>
<p>If the connection request times out, it may still be processing in the
background - a second call to <code>connect</code> or <code>connect_timeout</code> may fail.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.listen" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#253-255">source</a><h4 class="code-header">pub fn <a href="#method.listen" class="fn">listen</a>(&amp;self, backlog: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Mark a socket as ready to accept incoming connection requests using
<a href="struct.Socket.html#method.accept" title="method socket2::Socket::accept"><code>Socket::accept()</code></a>.</p>
<p>This function directly corresponds to the <code>listen(2)</code> function on
Windows and Unix.</p>
<p>An error will be returned if <code>listen</code> or <code>connect</code> has already been
called on this builder.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=listen&amp;section=2">https://man.dragonflybsd.org/?command=listen&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=listen&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=listen&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/listen.2.html">https://man7.org/linux/man-pages/man2/listen.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/listen.2">https://man.netbsd.org/listen.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/listen.2">https://man.openbsd.org/listen.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/listen">https://illumos.org/man/3SOCKET/listen</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.accept" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#265-299">source</a><h4 class="code-header">pub fn <a href="#method.accept" class="fn">accept</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)&gt;</h4></section></summary><div class="docblock"><p>Accept a new incoming connection from this listener.</p>
<p>This function uses <code>accept4(2)</code> on platforms that support it and
<code>accept(2)</code> platforms that do not.</p>
<p>This function sets the same flags as in done for <a href="struct.Socket.html#method.new" title="associated function socket2::Socket::new"><code>Socket::new</code></a>,
<a href="struct.Socket.html#method.accept_raw" title="method socket2::Socket::accept_raw"><code>Socket::accept_raw</code></a> can be used if you dont want to set those flags.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=accept&amp;section=2">https://man.dragonflybsd.org/?command=accept&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=accept&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=accept&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/accept.2.html">https://man7.org/linux/man-pages/man2/accept.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/accept.2">https://man.netbsd.org/accept.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/accept.2">https://man.openbsd.org/accept.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/accept">https://illumos.org/man/3SOCKET/accept</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.accept_raw" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#305-307">source</a><h4 class="code-header">pub fn <a href="#method.accept_raw" class="fn">accept_raw</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)&gt;</h4></section></summary><div class="docblock"><p>Accept a new incoming connection from this listener.</p>
<p>This function directly corresponds to the <code>accept(2)</code> function on
Windows and Unix.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.local_addr" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#321-323">source</a><h4 class="code-header">pub fn <a href="#method.local_addr" class="fn">local_addr</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the socket address of the local half of this socket.</p>
<p>This function directly corresponds to the <code>getsockname(2)</code> function on
Windows and Unix.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=getsockname&amp;section=2">https://man.dragonflybsd.org/?command=getsockname&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=getsockname&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=getsockname&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/getsockname.2.html">https://man7.org/linux/man-pages/man2/getsockname.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/getsockname.2">https://man.netbsd.org/getsockname.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/getsockname.2">https://man.openbsd.org/getsockname.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/getsockname">https://illumos.org/man/3SOCKET/getsockname</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname</a></li>
</ul>
<h5 id="notes-2"><a href="#notes-2">Notes</a></h5>
<p>Depending on the OS this may return an error if the socket is not
<a href="struct.Socket.html#method.bind" title="method socket2::Socket::bind">bound</a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.peer_addr" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#336-338">source</a><h4 class="code-header">pub fn <a href="#method.peer_addr" class="fn">peer_addr</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the socket address of the remote peer of this socket.</p>
<p>This function directly corresponds to the <code>getpeername(2)</code> function on
Windows and Unix.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=getpeername&amp;section=2">https://man.dragonflybsd.org/?command=getpeername&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=getpeername&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=getpeername&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/getpeername.2.html">https://man7.org/linux/man-pages/man2/getpeername.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/getpeername.2">https://man.netbsd.org/getpeername.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/getpeername.2">https://man.openbsd.org/getpeername.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/getpeername">https://illumos.org/man/3SOCKET/getpeername</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getpeername">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getpeername</a></li>
</ul>
<h5 id="notes-3"><a href="#notes-3">Notes</a></h5>
<p>This returns an error if the socket is not <a href="struct.Socket.html#method.connect" title="method socket2::Socket::connect"><code>connect</code>ed</a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.type" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#342-344">source</a><h4 class="code-header">pub fn <a href="#method.type" class="fn">type</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the <a href="struct.Type.html" title="struct socket2::Type"><code>Type</code></a> of this socket by checking the <code>SO_TYPE</code> option on
this socket.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_clone" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#359-361">source</a><h4 class="code-header">pub fn <a href="#method.try_clone" class="fn">try_clone</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt;</h4></section></summary><div class="docblock"><p>Creates a new independently owned handle to the underlying socket.</p>
<h5 id="notes-4"><a href="#notes-4">Notes</a></h5>
<p>On Unix this uses <code>F_DUPFD_CLOEXEC</code> and thus sets the <code>FD_CLOEXEC</code> on
the returned socket.</p>
<p>On Windows this uses <code>WSA_FLAG_NO_HANDLE_INHERIT</code> setting inheriting to
false.</p>
<p>On Windows this can <strong>not</strong> be used function cannot be used on a
QOS-enabled socket, see
<a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw</a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.nonblocking" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#373-375">source</a><h4 class="code-header">pub fn <a href="#method.nonblocking" class="fn">nonblocking</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Returns true if this socket is set to nonblocking mode, false otherwise.</p>
<h5 id="notes-5"><a href="#notes-5">Notes</a></h5>
<p>On Unix this corresponds to calling <code>fcntl</code> returning the value of
<code>O_NONBLOCK</code>.</p>
<p>On Windows it is not possible retrieve the nonblocking mode status.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_nonblocking" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#385-387">source</a><h4 class="code-header">pub fn <a href="#method.set_nonblocking" class="fn">set_nonblocking</a>(&amp;self, nonblocking: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Moves this socket into or out of nonblocking mode.</p>
<h5 id="notes-6"><a href="#notes-6">Notes</a></h5>
<p>On Unix this corresponds to calling <code>fcntl</code> (un)setting <code>O_NONBLOCK</code>.</p>
<p>On Windows this corresponds to calling <code>ioctlsocket</code> (un)setting
<code>FIONBIO</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.shutdown" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#394-396">source</a><h4 class="code-header">pub fn <a href="#method.shutdown" class="fn">shutdown</a>(&amp;self, how: <a class="enum" href="https://doc.rust-lang.org/1.76.0/std/net/enum.Shutdown.html" title="enum std::net::Shutdown">Shutdown</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Shuts down the read, write, or both halves of this connection.</p>
<p>This function will cause all pending and future I/O on the specified
portions to return immediately with an appropriate value.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=shutdown&amp;section=2">https://man.dragonflybsd.org/?command=shutdown&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=shutdown&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=shutdown&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/shutdown.2.html">https://man7.org/linux/man-pages/man2/shutdown.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/shutdown.2">https://man.netbsd.org/shutdown.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/shutdown.2">https://man.openbsd.org/shutdown.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/shutdown">https://illumos.org/man/3SOCKET/shutdown</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#419-421">source</a><h4 class="code-header">pub fn <a href="#method.recv" class="fn">recv</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Receives data on the socket from the remote address to which it is
connected.</p>
<p>The <a href="struct.Socket.html#method.connect" title="method socket2::Socket::connect"><code>connect</code></a> method will connect this socket to a remote address.
This method might fail if the socket is not connected.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recv&amp;section=2">https://man.dragonflybsd.org/?command=recv&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recv&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recv&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recv.2.html">https://man7.org/linux/man-pages/man2/recv.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/recv.2">https://man.netbsd.org/recv.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/recv.2">https://man.openbsd.org/recv.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recv">https://illumos.org/man/3SOCKET/recv</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv</a></li>
</ul>
<h5 id="safety"><a href="#safety">Safety</a></h5>
<p>Normally casting a <code>&amp;mut [u8]</code> to <code>&amp;mut [MaybeUninit&lt;u8&gt;]</code> would be
unsound, as that allows us to write uninitialised bytes to the buffer.
However this implementation promises to not write uninitialised bytes to
the <code>buf</code>fer and passes it directly to <code>recv(2)</code> system call. This
promise ensures that this function can be called using a <code>buf</code>fer of
type <code>&amp;mut [u8]</code>.</p>
<p>Note that the <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#tymethod.read" title="method std::io::Read::read"><code>io::Read::read</code></a> implementation calls this function with
a <code>buf</code>fer of type <code>&amp;mut [u8]</code>, allowing initialised buffers to be used
without using <code>unsafe</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_out_of_band" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#431-433">source</a><h4 class="code-header">pub fn <a href="#method.recv_out_of_band" class="fn">recv_out_of_band</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Receives out-of-band (OOB) data on the socket from the remote address to
which it is connected by setting the <code>MSG_OOB</code> flag for this call.</p>
<p>For more information, see <a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>, <a href="struct.Socket.html#method.out_of_band_inline" title="method socket2::Socket::out_of_band_inline"><code>out_of_band_inline</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#439-445">source</a><h4 class="code-header">pub fn <a href="#method.recv_with_flags" class="fn">recv_with_flags</a>(
&amp;self,
buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;],
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a> but allows for specification of arbitrary flags to
the underlying <code>recv</code> call.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#475-480">source</a><h4 class="code-header">pub fn <a href="#method.recv_vectored" class="fn">recv_vectored</a>(
&amp;self,
bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;]
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>)&gt;</h4></section></summary><div class="docblock"><p>Receives data on the socket from the remote address to which it is
connected. Unlike <a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a> this allows passing multiple buffers.</p>
<p>The <a href="struct.Socket.html#method.connect" title="method socket2::Socket::connect"><code>connect</code></a> method will connect this socket to a remote address.
This method might fail if the socket is not connected.</p>
<p>In addition to the number of bytes read, this function returns the flags
for the received message. See <a href="struct.RecvFlags.html" title="struct socket2::RecvFlags"><code>RecvFlags</code></a> for more information about
the returned flags.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvmsg&amp;section=2">https://man.dragonflybsd.org/?command=recvmsg&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvmsg&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvmsg&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvmsg.2.html">https://man7.org/linux/man-pages/man2/recvmsg.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/recvmsg.2">https://man.netbsd.org/recvmsg.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/recvmsg.2">https://man.openbsd.org/recvmsg.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvmsg">https://illumos.org/man/3SOCKET/recvmsg</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg</a></li>
</ul>
<h5 id="safety-1"><a href="#safety-1">Safety</a></h5>
<p>Normally casting a <code>IoSliceMut</code> to <code>MaybeUninitSlice</code> would be unsound,
as that allows us to write uninitialised bytes to the buffer. However
this implementation promises to not write uninitialised bytes to the
<code>bufs</code> and passes it directly to <code>recvmsg(2)</code> system call. This promise
ensures that this function can be called using <code>bufs</code> of type <code>&amp;mut [IoSliceMut]</code>.</p>
<p>Note that the <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_vectored" title="method std::io::Read::read_vectored"><code>io::Read::read_vectored</code></a> implementation calls this
function with <code>buf</code>s of type <code>&amp;mut [IoSliceMut]</code>, allowing initialised
buffers to be used without using <code>unsafe</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#495-501">source</a><h4 class="code-header">pub fn <a href="#method.recv_vectored_with_flags" class="fn">recv_vectored_with_flags</a>(
&amp;self,
bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;],
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>)&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a> but allows for specification of arbitrary
flags to the underlying <code>recvmsg</code>/<code>WSARecv</code> call.</p>
<h5 id="safety-2"><a href="#safety-2">Safety</a></h5>
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
as <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.peek" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#516-518">source</a><h4 class="code-header">pub fn <a href="#method.peek" class="fn">peek</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Receives data on the socket from the remote adress to which it is
connected, without removing that data from the queue. On success,
returns the number of bytes peeked.</p>
<p>Successive calls return the same data. This is accomplished by passing
<code>MSG_PEEK</code> as a flag to the underlying <code>recv</code> system call.</p>
<h5 id="safety-3"><a href="#safety-3">Safety</a></h5>
<p><code>peek</code> makes the same safety guarantees regarding the <code>buf</code>fer as
<a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#530-532">source</a><h4 class="code-header">pub fn <a href="#method.recv_from" class="fn">recv_from</a>(
&amp;self,
buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;]
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)&gt;</h4></section></summary><div class="docblock"><p>Receives data from the socket. On success, returns the number of bytes
read and the address from whence the data came.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvfrom&amp;section=2">https://man.dragonflybsd.org/?command=recvfrom&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvfrom&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvfrom&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvfrom.2.html">https://man7.org/linux/man-pages/man2/recvfrom.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/recvfrom.2">https://man.netbsd.org/recvfrom.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/recvfrom.2">https://man.openbsd.org/recvfrom.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvfrom">https://illumos.org/man/3SOCKET/recvfrom</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom</a></li>
</ul>
<h5 id="safety-4"><a href="#safety-4">Safety</a></h5>
<p><code>recv_from</code> makes the same safety guarantees regarding the <code>buf</code>fer as
<a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#538-544">source</a><h4 class="code-header">pub fn <a href="#method.recv_from_with_flags" class="fn">recv_from_with_flags</a>(
&amp;self,
buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;],
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv_from" title="method socket2::Socket::recv_from"><code>recv_from</code></a> but allows for specification of arbitrary
flags to the underlying <code>recvfrom</code> call.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#561-566">source</a><h4 class="code-header">pub fn <a href="#method.recv_from_vectored" class="fn">recv_from_vectored</a>(
&amp;self,
bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;]
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)&gt;</h4></section></summary><div class="docblock"><p>Receives data from the socket. Returns the amount of bytes read, the
<a href="struct.RecvFlags.html" title="struct socket2::RecvFlags"><code>RecvFlags</code></a> and the remote address from the data is coming. Unlike
<a href="struct.Socket.html#method.recv_from" title="method socket2::Socket::recv_from"><code>recv_from</code></a> this allows passing multiple buffers.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvmsg&amp;section=2">https://man.dragonflybsd.org/?command=recvmsg&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvmsg&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvmsg&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvmsg.2.html">https://man7.org/linux/man-pages/man2/recvmsg.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/recvmsg.2">https://man.netbsd.org/recvmsg.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/recvmsg.2">https://man.openbsd.org/recvmsg.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvmsg">https://illumos.org/man/3SOCKET/recvmsg</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg</a></li>
</ul>
<h5 id="safety-5"><a href="#safety-5">Safety</a></h5>
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
as <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#581-587">source</a><h4 class="code-header">pub fn <a href="#method.recv_from_vectored_with_flags" class="fn">recv_from_vectored_with_flags</a>(
&amp;self,
bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;],
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv_from_vectored" title="method socket2::Socket::recv_from_vectored"><code>recv_from_vectored</code></a> but allows for specification of
arbitrary flags to the underlying <code>recvmsg</code>/<code>WSARecvFrom</code> call.</p>
<h5 id="safety-6"><a href="#safety-6">Safety</a></h5>
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
as <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.peek_from" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#618-620">source</a><h4 class="code-header">pub fn <a href="#method.peek_from" class="fn">peek_from</a>(
&amp;self,
buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/1.76.0/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;]
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)&gt;</h4></section></summary><div class="docblock"><p>Receives data from the socket, without removing it from the queue.</p>
<p>Successive calls return the same data. This is accomplished by passing
<code>MSG_PEEK</code> as a flag to the underlying <code>recvfrom</code> system call.</p>
<p>On success, returns the number of bytes peeked and the address from
whence the data came.</p>
<h5 id="safety-7"><a href="#safety-7">Safety</a></h5>
<p><code>peek_from</code> makes the same safety guarantees regarding the <code>buf</code>fer as
<a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>.</p>
<h5 id="note-datagram-sockets"><a href="#note-datagram-sockets">Note: Datagram Sockets</a></h5>
<p>For datagram sockets, the behavior of this method when <code>buf</code> is smaller than
the datagram at the head of the receive queue differs between Windows and
Unix-like platforms (Linux, macOS, BSDs, etc: colloquially termed “*nix”).</p>
<p>On *nix platforms, the datagram is truncated to the length of <code>buf</code>.</p>
<p>On Windows, an error corresponding to <code>WSAEMSGSIZE</code> will be returned.</p>
<p>For consistency between platforms, be sure to provide a sufficiently large buffer to avoid
truncation; the exact size required depends on the underlying protocol.</p>
<p>If you just want to know the sender of the data, try <a href="struct.Socket.html#method.peek_sender" title="method socket2::Socket::peek_sender"><code>peek_sender</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.peek_sender" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#628-630">source</a><h4 class="code-header">pub fn <a href="#method.peek_sender" class="fn">peek_sender</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>&gt;</h4></section></summary><div class="docblock"><p>Retrieve the sender for the data at the head of the receive queue.</p>
<p>This is equivalent to calling <a href="struct.Socket.html#method.peek_from" title="method socket2::Socket::peek_from"><code>peek_from</code></a> with a zero-sized buffer,
but suppresses the <code>WSAEMSGSIZE</code> error on Windows.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recvmsg" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#641-643">source</a><h4 class="code-header">pub fn <a href="#method.recvmsg" class="fn">recvmsg</a>(
&amp;self,
msg: &amp;mut <a class="struct" href="struct.MsgHdrMut.html" title="struct socket2::MsgHdrMut">MsgHdrMut</a>&lt;'_, '_, '_&gt;,
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Receive a message from a socket using a message structure.</p>
<p>This is not supported on Windows as calling <code>WSARecvMsg</code> (the <code>recvmsg</code>
equivalent) is not straight forward on Windows. See
<a href="https://github.com/microsoft/Windows-classic-samples/blob/7cbd99ac1d2b4a0beffbaba29ea63d024ceff700/Samples/Win7Samples/netds/winsock/recvmsg/rmmc.cpp">https://github.com/microsoft/Windows-classic-samples/blob/7cbd99ac1d2b4a0beffbaba29ea63d024ceff700/Samples/Win7Samples/netds/winsock/recvmsg/rmmc.cpp</a>
for an example (in C++).</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvmsg&amp;section=2">https://man.dragonflybsd.org/?command=recvmsg&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvmsg&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvmsg&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvmsg.2.html">https://man7.org/linux/man-pages/man2/recvmsg.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/recvmsg.2">https://man.netbsd.org/recvmsg.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/recvmsg.2">https://man.openbsd.org/recvmsg.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvmsg">https://illumos.org/man/3SOCKET/recvmsg</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#652-654">source</a><h4 class="code-header">pub fn <a href="#method.send" class="fn">send</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Sends data on the socket to a connected peer.</p>
<p>This is typically used on TCP sockets or datagram sockets which have
been connected.</p>
<p>On success returns the number of bytes that were sent.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=send&amp;section=2">https://man.dragonflybsd.org/?command=send&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=send&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=send&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/send.2.html">https://man7.org/linux/man-pages/man2/send.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/send.2">https://man.netbsd.org/send.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/send.2">https://man.openbsd.org/send.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/send">https://illumos.org/man/3SOCKET/send</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#660-662">source</a><h4 class="code-header">pub fn <a href="#method.send_with_flags" class="fn">send_with_flags</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>], flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send" title="method socket2::Socket::send"><code>send</code></a> but allows for specification of arbitrary flags to the underlying
<code>send</code> call.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#667-669">source</a><h4 class="code-header">pub fn <a href="#method.send_vectored" class="fn">send_vectored</a>(&amp;self, bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Send data to the connected peer. Returns the amount of bytes written.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#678-684">source</a><h4 class="code-header">pub fn <a href="#method.send_vectored_with_flags" class="fn">send_vectored_with_flags</a>(
&amp;self,
bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;],
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send_vectored" title="method socket2::Socket::send_vectored"><code>send_vectored</code></a> but allows for specification of arbitrary
flags to the underlying <code>sendmsg</code>/<code>WSASend</code> call.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendmsg&amp;section=2">https://man.dragonflybsd.org/?command=sendmsg&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendmsg&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendmsg&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendmsg.2.html">https://man7.org/linux/man-pages/man2/sendmsg.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/sendmsg.2">https://man.netbsd.org/sendmsg.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/sendmsg.2">https://man.openbsd.org/sendmsg.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendmsg">https://illumos.org/man/3SOCKET/sendmsg</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_out_of_band" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#694-696">source</a><h4 class="code-header">pub fn <a href="#method.send_out_of_band" class="fn">send_out_of_band</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Sends out-of-band (OOB) data on the socket to connected peer
by setting the <code>MSG_OOB</code> flag for this call.</p>
<p>For more information, see <a href="struct.Socket.html#method.send" title="method socket2::Socket::send"><code>send</code></a>, <a href="struct.Socket.html#method.out_of_band_inline" title="method socket2::Socket::out_of_band_inline"><code>out_of_band_inline</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#703-705">source</a><h4 class="code-header">pub fn <a href="#method.send_to" class="fn">send_to</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>], addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Sends data on the socket to the given address. On success, returns the
number of bytes written.</p>
<p>This is typically used on UDP or datagram-oriented sockets.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendto&amp;section=2">https://man.dragonflybsd.org/?command=sendto&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendto&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendto&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendto.2.html">https://man7.org/linux/man-pages/man2/sendto.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/sendto.2">https://man.netbsd.org/sendto.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/sendto.2">https://man.openbsd.org/sendto.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendto">https://illumos.org/man/3SOCKET/sendto</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#711-718">source</a><h4 class="code-header">pub fn <a href="#method.send_to_with_flags" class="fn">send_to_with_flags</a>(
&amp;self,
buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>],
addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>,
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send_to" title="method socket2::Socket::send_to"><code>send_to</code></a> but allows for specification of arbitrary flags
to the underlying <code>sendto</code> call.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#725-727">source</a><h4 class="code-header">pub fn <a href="#method.send_to_vectored" class="fn">send_to_vectored</a>(
&amp;self,
bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;],
addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Send data to a peer listening on <code>addr</code>. Returns the amount of bytes
written.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendmsg&amp;section=2">https://man.dragonflybsd.org/?command=sendmsg&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendmsg&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendmsg&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendmsg.2.html">https://man7.org/linux/man-pages/man2/sendmsg.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/sendmsg.2">https://man.netbsd.org/sendmsg.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/sendmsg.2">https://man.openbsd.org/sendmsg.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendmsg">https://illumos.org/man/3SOCKET/sendmsg</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg</a></li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#735-742">source</a><h4 class="code-header">pub fn <a href="#method.send_to_vectored_with_flags" class="fn">send_to_vectored_with_flags</a>(
&amp;self,
bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;],
addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>,
flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send_to_vectored" title="method socket2::Socket::send_to_vectored"><code>send_to_vectored</code></a> but allows for specification of
arbitrary flags to the underlying <code>sendmsg</code>/<code>WSASendTo</code> call.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.sendmsg" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#748-750">source</a><h4 class="code-header">pub fn <a href="#method.sendmsg" class="fn">sendmsg</a>(&amp;self, msg: &amp;<a class="struct" href="struct.MsgHdr.html" title="struct socket2::MsgHdr">MsgHdr</a>&lt;'_, '_, '_&gt;, flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Send a message on a socket using a message structure.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendmsg&amp;section=2">https://man.dragonflybsd.org/?command=sendmsg&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendmsg&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendmsg&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendmsg.2.html">https://man7.org/linux/man-pages/man2/sendmsg.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/sendmsg.2">https://man.netbsd.org/sendmsg.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/sendmsg.2">https://man.openbsd.org/sendmsg.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendmsg">https://illumos.org/man/3SOCKET/sendmsg</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg</a></li>
</ul>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-1" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#835-1079">source</a><a href="#impl-Socket-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="docblock"><p>Socket options get/set using <code>SOL_SOCKET</code>.</p>
<p>Additional documentation can be found in documentation of the OS.</p>
<ul>
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/socket.7.html">https://man7.org/linux/man-pages/man7/socket.7.html</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options</a></li>
</ul>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.broadcast" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#841-846">source</a><h4 class="code-header">pub fn <a href="#method.broadcast" class="fn">broadcast</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_BROADCAST</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_broadcast" title="method socket2::Socket::set_broadcast"><code>set_broadcast</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_broadcast" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#852-861">source</a><h4 class="code-header">pub fn <a href="#method.set_broadcast" class="fn">set_broadcast</a>(&amp;self, broadcast: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>SO_BROADCAST</code> option for this socket.</p>
<p>When enabled, this socket is allowed to send packets to a broadcast
address.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.take_error" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#868-874">source</a><h4 class="code-header">pub fn <a href="#method.take_error" class="fn">take_error</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_ERROR</code> option on this socket.</p>
<p>This will retrieve the stored error in the underlying socket, clearing
the field in the process. This can be useful for checking errors between
calls.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.keepalive" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#881-886">source</a><h4 class="code-header">pub fn <a href="#method.keepalive" class="fn">keepalive</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_KEEPALIVE</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_keepalive" title="method socket2::Socket::set_keepalive"><code>set_keepalive</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_keepalive" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#891-900">source</a><h4 class="code-header">pub fn <a href="#method.set_keepalive" class="fn">set_keepalive</a>(&amp;self, keepalive: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_KEEPALIVE</code> option on this socket.</p>
<p>Enable sending of keep-alive messages on connection-oriented sockets.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.linger" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#907-912">source</a><h4 class="code-header">pub fn <a href="#method.linger" class="fn">linger</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_LINGER</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_linger" title="method socket2::Socket::set_linger"><code>set_linger</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_linger" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#928-931">source</a><h4 class="code-header">pub fn <a href="#method.set_linger" class="fn">set_linger</a>(&amp;self, linger: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_LINGER</code> option on this socket.</p>
<p>If <code>linger</code> is not <code>None</code>, a close(2) or shutdown(2) will not return
until all queued messages for the socket have been successfully sent or
the linger timeout has been reached. Otherwise, the call returns
immediately and the closing is done in the background. When the socket
is closed as part of exit(2), it always lingers in the background.</p>
<h5 id="notes-7"><a href="#notes-7">Notes</a></h5>
<p>On most OSs the duration only has a precision of seconds and will be
silently truncated.</p>
<p>On Apple platforms (e.g. macOS, iOS, etc) this uses <code>SO_LINGER_SEC</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.out_of_band_inline" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#940-945">source</a><h4 class="code-header">pub fn <a href="#method.out_of_band_inline" class="fn">out_of_band_inline</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get value for the <code>SO_OOBINLINE</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_out_of_band_inline" title="method socket2::Socket::set_out_of_band_inline"><code>set_out_of_band_inline</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_out_of_band_inline" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#955-964">source</a><h4 class="code-header">pub fn <a href="#method.set_out_of_band_inline" class="fn">set_out_of_band_inline</a>(&amp;self, oob_inline: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_OOBINLINE</code> option on this socket.</p>
<p>If this option is enabled, out-of-band data is directly placed into the
receive data stream. Otherwise, out-of-band data is passed only when the
<code>MSG_OOB</code> flag is set during receiving. As per RFC6093, TCP sockets
using the Urgent mechanism are encouraged to set this flag.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#971-976">source</a><h4 class="code-header">pub fn <a href="#method.recv_buffer_size" class="fn">recv_buffer_size</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Get value for the <code>SO_RCVBUF</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_recv_buffer_size" title="method socket2::Socket::set_recv_buffer_size"><code>set_recv_buffer_size</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_recv_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#982-991">source</a><h4 class="code-header">pub fn <a href="#method.set_recv_buffer_size" class="fn">set_recv_buffer_size</a>(&amp;self, size: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_RCVBUF</code> option on this socket.</p>
<p>Changes the size of the operating systems receive buffer associated
with the socket.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.read_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#997-999">source</a><h4 class="code-header">pub fn <a href="#method.read_timeout" class="fn">read_timeout</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Get value for the <code>SO_RCVTIMEO</code> option on this socket.</p>
<p>If the returned timeout is <code>None</code>, then <code>read</code> and <code>recv</code> calls will
block indefinitely.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_read_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1005-1007">source</a><h4 class="code-header">pub fn <a href="#method.set_read_timeout" class="fn">set_read_timeout</a>(&amp;self, duration: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_RCVTIMEO</code> option on this socket.</p>
<p>If <code>timeout</code> is <code>None</code>, then <code>read</code> and <code>recv</code> calls will block
indefinitely.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.reuse_address" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1014-1019">source</a><h4 class="code-header">pub fn <a href="#method.reuse_address" class="fn">reuse_address</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_REUSEADDR</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_reuse_address" title="method socket2::Socket::set_reuse_address"><code>set_reuse_address</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_reuse_address" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1026-1035">source</a><h4 class="code-header">pub fn <a href="#method.set_reuse_address" class="fn">set_reuse_address</a>(&amp;self, reuse: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_REUSEADDR</code> option on this socket.</p>
<p>This indicates that futher calls to <code>bind</code> may allow reuse of local
addresses. For IPv4 sockets this means that a socket may bind even when
theres a socket already listening on this port.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1042-1047">source</a><h4 class="code-header">pub fn <a href="#method.send_buffer_size" class="fn">send_buffer_size</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_SNDBUF</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_send_buffer_size" title="method socket2::Socket::set_send_buffer_size"><code>set_send_buffer_size</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_send_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1053-1062">source</a><h4 class="code-header">pub fn <a href="#method.set_send_buffer_size" class="fn">set_send_buffer_size</a>(&amp;self, size: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_SNDBUF</code> option on this socket.</p>
<p>Changes the size of the operating systems send buffer associated with
the socket.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1068-1070">source</a><h4 class="code-header">pub fn <a href="#method.write_timeout" class="fn">write_timeout</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Get value for the <code>SO_SNDTIMEO</code> option on this socket.</p>
<p>If the returned timeout is <code>None</code>, then <code>write</code> and <code>send</code> calls will
block indefinitely.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_write_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1076-1078">source</a><h4 class="code-header">pub fn <a href="#method.set_write_timeout" class="fn">set_write_timeout</a>(&amp;self, duration: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_SNDTIMEO</code> option on this socket.</p>
<p>If <code>timeout</code> is <code>None</code>, then <code>write</code> and <code>send</code> calls will block
indefinitely.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-2" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#1107-1570">source</a><a href="#impl-Socket-2" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="docblock"><p>Socket options for IPv4 sockets, get/set using <code>IPPROTO_IP</code>.</p>
<p>Additional documentation can be found in documentation of the OS.</p>
<ul>
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/ip.7.html">https://man7.org/linux/man-pages/man7/ip.7.html</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options</a></li>
</ul>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.header_included" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1118-1123">source</a><h4 class="code-header">pub fn <a href="#method.header_included" class="fn">header_included</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_HDRINCL</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_header_included" title="method socket2::Socket::set_header_included"><code>set_header_included</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_header_included" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1145-1154">source</a><h4 class="code-header">pub fn <a href="#method.set_header_included" class="fn">set_header_included</a>(&amp;self, included: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_HDRINCL</code> option on this socket.</p>
<p>If enabled, the user supplies an IP header in front of the user data.
Valid only for <a href="struct.Type.html#associatedconstant.RAW" title="associated constant socket2::Type::RAW"><code>SOCK_RAW</code></a> sockets; see <a href="https://man7.org/linux/man-pages/man7/raw.7.html">raw(7)</a> for more information.
When this flag is enabled, the values set by <code>IP_OPTIONS</code>, <a href="struct.Socket.html#method.set_ttl" title="method socket2::Socket::set_ttl"><code>IP_TTL</code></a>,
and <a href="struct.Socket.html#method.set_tos" title="method socket2::Socket::set_tos"><code>IP_TOS</code></a> are ignored.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.join_multicast_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1205-1211">source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v4" class="fn">join_multicast_v4</a>(
&amp;self,
multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
interface: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Join a multicast group using <code>IP_ADD_MEMBERSHIP</code> option on this socket.</p>
<p>This function specifies a new multicast group for this socket to join.
The address must be a valid multicast address, and <code>interface</code> is the
address of the local interface with which the system should join the
multicast group. If its <a href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED" title="associated constant core::net::ip_addr::Ipv4Addr::UNSPECIFIED"><code>Ipv4Addr::UNSPECIFIED</code></a> (<code>INADDR_ANY</code>) then
an appropriate interface is chosen by the system.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_multicast_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1218-1231">source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v4" class="fn">leave_multicast_v4</a>(
&amp;self,
multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
interface: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IP_DROP_MEMBERSHIP</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.join_multicast_v4" title="method socket2::Socket::join_multicast_v4"><code>join_multicast_v4</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.join_multicast_v4_n" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1251-1265">source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v4_n" class="fn">join_multicast_v4_n</a>(
&amp;self,
multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
interface: &amp;<a class="enum" href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress">InterfaceIndexOrAddress</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Join a multicast group using <code>IP_ADD_MEMBERSHIP</code> option on this socket.</p>
<p>This function specifies a new multicast group for this socket to join.
The address must be a valid multicast address, and <code>interface</code> specifies
the local interface with which the system should join the multicast
group. See <a href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress"><code>InterfaceIndexOrAddress</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_multicast_v4_n" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1284-1298">source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v4_n" class="fn">leave_multicast_v4_n</a>(
&amp;self,
multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
interface: &amp;<a class="enum" href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress">InterfaceIndexOrAddress</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IP_DROP_MEMBERSHIP</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.join_multicast_v4_n" title="method socket2::Socket::join_multicast_v4_n"><code>join_multicast_v4_n</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.join_ssm_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1318-1337">source</a><h4 class="code-header">pub fn <a href="#method.join_ssm_v4" class="fn">join_ssm_v4</a>(
&amp;self,
source: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
group: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
interface: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Join a multicast SSM channel using <code>IP_ADD_SOURCE_MEMBERSHIP</code> option on this socket.</p>
<p>This function specifies a new multicast channel for this socket to join.
The group must be a valid SSM group address, the source must be the address of the sender
and <code>interface</code> is the address of the local interface with which the system should join the
multicast group. If its <a href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED" title="associated constant core::net::ip_addr::Ipv4Addr::UNSPECIFIED"><code>Ipv4Addr::UNSPECIFIED</code></a> (<code>INADDR_ANY</code>) then
an appropriate interface is chosen by the system.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_ssm_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1355-1374">source</a><h4 class="code-header">pub fn <a href="#method.leave_ssm_v4" class="fn">leave_ssm_v4</a>(
&amp;self,
source: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
group: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
interface: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IP_DROP_SOURCE_MEMBERSHIP</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.join_ssm_v4" title="method socket2::Socket::join_ssm_v4"><code>join_ssm_v4</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_if_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1381-1385">source</a><h4 class="code-header">pub fn <a href="#method.multicast_if_v4" class="fn">multicast_if_v4</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_MULTICAST_IF</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_if_v4" title="method socket2::Socket::set_multicast_if_v4"><code>set_multicast_if_v4</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_if_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1390-1400">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_if_v4" class="fn">set_multicast_if_v4</a>(&amp;self, interface: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_MULTICAST_IF</code> option for this socket.</p>
<p>Specifies the interface to use for routing multicast packets.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_loop_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1407-1412">source</a><h4 class="code-header">pub fn <a href="#method.multicast_loop_v4" class="fn">multicast_loop_v4</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_MULTICAST_LOOP</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_loop_v4" title="method socket2::Socket::set_multicast_loop_v4"><code>set_multicast_loop_v4</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_loop_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1418-1427">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_loop_v4" class="fn">set_multicast_loop_v4</a>(&amp;self, loop_v4: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_MULTICAST_LOOP</code> option for this socket.</p>
<p>If enabled, multicast packets will be looped back to the local socket.
Note that this may not have any affect on IPv6 sockets.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_ttl_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1434-1439">source</a><h4 class="code-header">pub fn <a href="#method.multicast_ttl_v4" class="fn">multicast_ttl_v4</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_MULTICAST_TTL</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_ttl_v4" title="method socket2::Socket::set_multicast_ttl_v4"><code>set_multicast_ttl_v4</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_ttl_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1448-1457">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_ttl_v4" class="fn">set_multicast_ttl_v4</a>(&amp;self, ttl: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_MULTICAST_TTL</code> option for this socket.</p>
<p>Indicates the time-to-live value of outgoing multicast packets for
this socket. The default value is 1 which means that multicast packets
dont leave the local network unless explicitly requested.</p>
<p>Note that this may not have any affect on IPv6 sockets.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ttl" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1464-1468">source</a><h4 class="code-header">pub fn <a href="#method.ttl" class="fn">ttl</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_TTL</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_ttl" title="method socket2::Socket::set_ttl"><code>set_ttl</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_ttl" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1474-1476">source</a><h4 class="code-header">pub fn <a href="#method.set_ttl" class="fn">set_ttl</a>(&amp;self, ttl: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_TTL</code> option for this socket.</p>
<p>This value sets the time-to-live field that is used in every packet sent
from this socket.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tos" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1491-1493">source</a><h4 class="code-header">pub fn <a href="#method.set_tos" class="fn">set_tos</a>(&amp;self, tos: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_TOS</code> option for this socket.</p>
<p>This value sets the type-of-service field that is used in every packet
sent from this socket.</p>
<p>NOTE: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options</a>
documents that not all versions of windows support <code>IP_TOS</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.tos" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1509-1513">source</a><h4 class="code-header">pub fn <a href="#method.tos" class="fn">tos</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_TOS</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tos" title="method socket2::Socket::set_tos"><code>set_tos</code></a>.</p>
<p>NOTE: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options</a>
documents that not all versions of windows support <code>IP_TOS</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_recv_tos" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1534-1543">source</a><h4 class="code-header">pub fn <a href="#method.set_recv_tos" class="fn">set_recv_tos</a>(&amp;self, recv_tos: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_RECVTOS</code> option for this socket.</p>
<p>If enabled, the <code>IP_TOS</code> ancillary message is passed with
incoming packets. It contains a byte which specifies the
Type of Service/Precedence field of the packet header.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_tos" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1564-1569">source</a><h4 class="code-header">pub fn <a href="#method.recv_tos" class="fn">recv_tos</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_RECVTOS</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_recv_tos" title="method socket2::Socket::set_recv_tos"><code>set_recv_tos</code></a>.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-3" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#1577-1815">source</a><a href="#impl-Socket-3" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="docblock"><p>Socket options for IPv6 sockets, get/set using <code>IPPROTO_IPV6</code>.</p>
<p>Additional documentation can be found in documentation of the OS.</p>
<ul>
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/ipv6.7.html">https://man7.org/linux/man-pages/man7/ipv6.7.html</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options</a></li>
</ul>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.join_multicast_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1586-1600">source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v6" class="fn">join_multicast_v6</a>(
&amp;self,
multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv6Addr.html" title="struct core::net::ip_addr::Ipv6Addr">Ipv6Addr</a>,
interface: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Join a multicast group using <code>IPV6_ADD_MEMBERSHIP</code> option on this socket.</p>
<p>Some OSs use <code>IPV6_JOIN_GROUP</code> for this option.</p>
<p>This function specifies a new multicast group for this socket to join.
The address must be a valid multicast address, and <code>interface</code> is the
index of the interface to join/leave (or 0 to indicate any interface).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_multicast_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1610-1624">source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v6" class="fn">leave_multicast_v6</a>(
&amp;self,
multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/net/ip_addr/struct.Ipv6Addr.html" title="struct core::net::ip_addr::Ipv6Addr">Ipv6Addr</a>,
interface: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IPV6_DROP_MEMBERSHIP</code> option on this socket.</p>
<p>Some OSs use <code>IPV6_LEAVE_GROUP</code> for this option.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.join_multicast_v6" title="method socket2::Socket::join_multicast_v6"><code>join_multicast_v6</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1631-1636">source</a><h4 class="code-header">pub fn <a href="#method.multicast_hops_v6" class="fn">multicast_hops_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_MULTICAST_HOPS</code> option for this socket</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_hops_v6" title="method socket2::Socket::set_multicast_hops_v6"><code>set_multicast_hops_v6</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1643-1652">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_hops_v6" class="fn">set_multicast_hops_v6</a>(&amp;self, hops: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_MULTICAST_HOPS</code> option for this socket</p>
<p>Indicates the number of “routers” multicast packets will transit for
this socket. The default value is 1 which means that multicast packets
dont leave the local network unless explicitly requested.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_if_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1659-1664">source</a><h4 class="code-header">pub fn <a href="#method.multicast_if_v6" class="fn">multicast_if_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_MULTICAST_IF</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_if_v6" title="method socket2::Socket::set_multicast_if_v6"><code>set_multicast_if_v6</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_if_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1671-1680">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_if_v6" class="fn">set_multicast_if_v6</a>(&amp;self, interface: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_MULTICAST_IF</code> option for this socket.</p>
<p>Specifies the interface to use for routing multicast packets. Unlike
ipv4, this is generally required in ipv6 contexts where network routing
prefixes may overlap.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_loop_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1687-1692">source</a><h4 class="code-header">pub fn <a href="#method.multicast_loop_v6" class="fn">multicast_loop_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_MULTICAST_LOOP</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_loop_v6" title="method socket2::Socket::set_multicast_loop_v6"><code>set_multicast_loop_v6</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_loop_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1698-1707">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_loop_v6" class="fn">set_multicast_loop_v6</a>(&amp;self, loop_v6: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_MULTICAST_LOOP</code> option for this socket.</p>
<p>Controls whether this socket sees the multicast packets it sends itself.
Note that this may not have any affect on IPv4 sockets.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.unicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1712-1717">source</a><h4 class="code-header">pub fn <a href="#method.unicast_hops_v6" class="fn">unicast_hops_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_UNICAST_HOPS</code> option for this socket.</p>
<p>Specifies the hop limit for ipv6 unicast packets</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_unicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1722-1731">source</a><h4 class="code-header">pub fn <a href="#method.set_unicast_hops_v6" class="fn">set_unicast_hops_v6</a>(&amp;self, hops: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value for the <code>IPV6_UNICAST_HOPS</code> option on this socket.</p>
<p>Specifies the hop limit for ipv6 unicast packets</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.only_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1738-1743">source</a><h4 class="code-header">pub fn <a href="#method.only_v6" class="fn">only_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_V6ONLY</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_only_v6" title="method socket2::Socket::set_only_v6"><code>set_only_v6</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_only_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1753-1762">source</a><h4 class="code-header">pub fn <a href="#method.set_only_v6" class="fn">set_only_v6</a>(&amp;self, only_v6: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value for the <code>IPV6_V6ONLY</code> option on this socket.</p>
<p>If this is set to <code>true</code> then the socket is restricted to sending and
receiving IPv6 packets only. In this case two IPv4 and IPv6 applications
can bind the same port at the same time.</p>
<p>If this is set to <code>false</code> then the socket can be used to send and
receive packets from an IPv4-mapped IPv6 address.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_tclass_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1781-1786">source</a><h4 class="code-header">pub fn <a href="#method.recv_tclass_v6" class="fn">recv_tclass_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_RECVTCLASS</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_recv_tclass_v6" title="method socket2::Socket::set_recv_tclass_v6"><code>set_recv_tclass_v6</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_recv_tclass_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1805-1814">source</a><h4 class="code-header">pub fn <a href="#method.set_recv_tclass_v6" class="fn">set_recv_tclass_v6</a>(&amp;self, recv_tclass: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_RECVTCLASS</code> option for this socket.</p>
<p>If enabled, the <code>IPV6_TCLASS</code> ancillary message is passed with incoming
packets. It contains a byte which specifies the traffic class field of
the packet header.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-4" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#1822-2018">source</a><a href="#impl-Socket-4" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="docblock"><p>Socket options for TCP sockets, get/set using <code>IPPROTO_TCP</code>.</p>
<p>Additional documentation can be found in documentation of the OS.</p>
<ul>
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/tcp.7.html">https://man7.org/linux/man-pages/man7/tcp.7.html</a></li>
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options</a></li>
</ul>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.keepalive_time" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1848-1850">source</a><h4 class="code-header">pub fn <a href="#method.keepalive_time" class="fn">keepalive_time</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_KEEPIDLE</code> option on this socket.</p>
<p>This returns the value of <code>TCP_KEEPALIVE</code> on macOS and iOS and <code>TCP_KEEPIDLE</code> on all other
supported Unix operating systems.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.keepalive_interval" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1892-1897">source</a><h4 class="code-header">pub fn <a href="#method.keepalive_interval" class="fn">keepalive_interval</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_KEEPINTVL</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_keepalive" title="method socket2::Socket::set_tcp_keepalive"><code>set_tcp_keepalive</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.keepalive_retries" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1939-1944">source</a><h4 class="code-header">pub fn <a href="#method.keepalive_retries" class="fn">keepalive_retries</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_KEEPCNT</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_keepalive" title="method socket2::Socket::set_tcp_keepalive"><code>set_tcp_keepalive</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_keepalive" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1984-1987">source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_keepalive" class="fn">set_tcp_keepalive</a>(&amp;self, params: &amp;<a class="struct" href="struct.TcpKeepalive.html" title="struct socket2::TcpKeepalive">TcpKeepalive</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set parameters configuring TCP keepalive probes for this socket.</p>
<p>The supported parameters depend on the operating system, and are
configured using the <a href="struct.TcpKeepalive.html" title="struct socket2::TcpKeepalive"><code>TcpKeepalive</code></a> struct. At a minimum, all systems
support configuring the <a href="struct.TcpKeepalive.html#method.with_time" title="method socket2::TcpKeepalive::with_time">keepalive time</a>: the time after which the OS
will start sending keepalive messages on an idle connection.</p>
<h5 id="notes-8"><a href="#notes-8">Notes</a></h5>
<ul>
<li>This will enable <code>SO_KEEPALIVE</code> on this socket, if it is not already
enabled.</li>
<li>On some platforms, such as Windows, any keepalive parameters <em>not</em>
configured by the <code>TcpKeepalive</code> struct passed to this function may be
overwritten with their default values. Therefore, this function should
either only be called once per socket, or the same parameters should
be passed every time it is called.</li>
</ul>
<h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::time::Duration;
<span class="kw">use </span>socket2::{Socket, TcpKeepalive, Domain, Type};
<span class="kw">let </span>socket = Socket::new(Domain::IPV4, Type::STREAM, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>keepalive = TcpKeepalive::new()
.with_time(Duration::from_secs(<span class="number">4</span>));
<span class="comment">// Depending on the target operating system, we may also be able to
// configure the keepalive probe interval and/or the number of
// retries here as well.
</span>socket.set_tcp_keepalive(<span class="kw-2">&amp;</span>keepalive)<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.nodelay" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1994-1999">source</a><h4 class="code-header">pub fn <a href="#method.nodelay" class="fn">nodelay</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_NODELAY</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_nodelay" title="method socket2::Socket::set_nodelay"><code>set_nodelay</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_nodelay" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2008-2017">source</a><h4 class="code-header">pub fn <a href="#method.set_nodelay" class="fn">set_nodelay</a>(&amp;self, nodelay: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_NODELAY</code> option on this socket.</p>
<p>If set, this option disables the Nagle algorithm. This means that
segments are always sent as soon as possible, even if there is only a
small amount of data. When not set, data is buffered until there is a
sufficient amount to send out, thereby avoiding the frequent sending of
small packets.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-5" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1343-3014">source</a><a href="#impl-Socket-5" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="docblock"><p>Unix only API.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.set_cloexec" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1421-1423">source</a><h4 class="code-header">pub fn <a href="#method.set_cloexec" class="fn">set_cloexec</a>(&amp;self, close_on_exec: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets <code>CLOEXEC</code> on the socket.</p>
<h5 id="notes-9"><a href="#notes-9">Notes</a></h5>
<p>On supported platforms you can use [<code>Type::cloexec</code>].</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_nosigpipe" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1466-1468">source</a><h4 class="code-header">pub fn <a href="#method.set_nosigpipe" class="fn">set_nosigpipe</a>(&amp;self, nosigpipe: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets <code>SO_NOSIGPIPE</code> on the socket.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.mss" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1494-1499">source</a><h4 class="code-header">pub fn <a href="#method.mss" class="fn">mss</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Gets the value of the <code>TCP_MAXSEG</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_mss" title="method socket2::Socket::set_mss"><code>set_mss</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_mss" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1507-1516">source</a><h4 class="code-header">pub fn <a href="#method.set_mss" class="fn">set_mss</a>(&amp;self, mss: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets the value of the <code>TCP_MAXSEG</code> option on this socket.</p>
<p>The <code>TCP_MAXSEG</code> option denotes the TCP Maximum Segment Size and is only
available on TCP sockets.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind_device_by_index" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1926-1928">source</a><h4 class="code-header">pub fn <a href="#method.bind_device_by_index" class="fn">bind_device_by_index</a>(&amp;self, interface: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/num/nonzero/struct.NonZeroU32.html" title="struct core::num::nonzero::NonZeroU32">NonZeroU32</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated: Use <code>Socket::bind_device_by_index_v4</code> instead</span></div></span></summary><div class="docblock"><p>This method is deprecated, use <a href="struct.Socket.html#method.bind_device_by_index_v4" title="method socket2::Socket::bind_device_by_index_v4"><code>crate::Socket::bind_device_by_index_v4</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind_device_by_index_v4" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1961-1964">source</a><h4 class="code-header">pub fn <a href="#method.bind_device_by_index_v4" class="fn">bind_device_by_index_v4</a>(
&amp;self,
interface: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/num/nonzero/struct.NonZeroU32.html" title="struct core::num::nonzero::NonZeroU32">NonZeroU32</a>&gt;
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets the value for <code>IP_BOUND_IF</code> option on this socket.</p>
<p>If a socket is bound to an interface, only packets received from that
particular interface are processed by the socket.</p>
<p>If <code>interface</code> is <code>None</code>, the binding is removed. If the <code>interface</code>
index is not valid, an error is returned.</p>
<p>One can use <a href="../libc/unix/fn.if_nametoindex.html" title="fn libc::unix::if_nametoindex"><code>libc::if_nametoindex</code></a> to convert an interface alias to an
index.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind_device_by_index_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1997-2000">source</a><h4 class="code-header">pub fn <a href="#method.bind_device_by_index_v6" class="fn">bind_device_by_index_v6</a>(
&amp;self,
interface: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/num/nonzero/struct.NonZeroU32.html" title="struct core::num::nonzero::NonZeroU32">NonZeroU32</a>&gt;
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets the value for <code>IPV6_BOUND_IF</code> option on this socket.</p>
<p>If a socket is bound to an interface, only packets received from that
particular interface are processed by the socket.</p>
<p>If <code>interface</code> is <code>None</code>, the binding is removed. If the <code>interface</code>
index is not valid, an error is returned.</p>
<p>One can use <a href="../libc/unix/fn.if_nametoindex.html" title="fn libc::unix::if_nametoindex"><code>libc::if_nametoindex</code></a> to convert an interface alias to an
index.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.device_index_v4" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2028-2032">source</a><h4 class="code-header">pub fn <a href="#method.device_index_v4" class="fn">device_index_v4</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/num/nonzero/struct.NonZeroU32.html" title="struct core::num::nonzero::NonZeroU32">NonZeroU32</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Gets the value for <code>IP_BOUND_IF</code> option on this socket, i.e. the index
for the interface to which the socket is bound.</p>
<p>Returns <code>None</code> if the socket is not bound to any interface, otherwise
returns an interface index.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.device_index" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2057-2059">source</a><h4 class="code-header">pub fn <a href="#method.device_index" class="fn">device_index</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/num/nonzero/struct.NonZeroU32.html" title="struct core::num::nonzero::NonZeroU32">NonZeroU32</a>&gt;&gt;</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated: Use <code>Socket::device_index_v4</code> instead</span></div></span></summary><div class="docblock"><p>This method is deprecated, use <a href="struct.Socket.html#method.device_index_v4" title="method socket2::Socket::device_index_v4"><code>crate::Socket::device_index_v4</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.device_index_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2087-2092">source</a><h4 class="code-header">pub fn <a href="#method.device_index_v6" class="fn">device_index_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/num/nonzero/struct.NonZeroU32.html" title="struct core::num::nonzero::NonZeroU32">NonZeroU32</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Gets the value for <code>IPV6_BOUND_IF</code> option on this socket, i.e. the index
for the interface to which the socket is bound.</p>
<p>Returns <code>None</code> if the socket is not bound to any interface, otherwise
returns an interface index.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.reuse_port" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2141-2146">source</a><h4 class="code-header">pub fn <a href="#method.reuse_port" class="fn">reuse_port</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_REUSEPORT</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_reuse_port" title="method socket2::Socket::set_reuse_port"><code>set_reuse_port</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_reuse_port" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2165-2174">source</a><h4 class="code-header">pub fn <a href="#method.set_reuse_port" class="fn">set_reuse_port</a>(&amp;self, reuse: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_REUSEPORT</code> option on this socket.</p>
<p>This indicates that further calls to <code>bind</code> may allow reuse of local
addresses. For IPv4 sockets this means that a socket may bind even when
theres a socket already listening on this port.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.sendfile" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2426-2436">source</a><h4 class="code-header">pub fn <a href="#method.sendfile" class="fn">sendfile</a>&lt;F&gt;(
&amp;self,
file: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&amp;F</a>,
offset: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>,
length: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/core/num/nonzero/struct.NonZeroUsize.html" title="struct core::num::nonzero::NonZeroUsize">NonZeroUsize</a>&gt;
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.AsRawFd.html" title="trait std::os::fd::raw::AsRawFd">AsRawFd</a>,</div></h4></section></summary><div class="docblock"><p>Copies data between a <code>file</code> and this socket using the <code>sendfile(2)</code>
system call. Because this copying is done within the kernel,
<code>sendfile()</code> is more efficient than the combination of <code>read(2)</code> and
<code>write(2)</code>, which would require transferring data to and from user
space.</p>
<p>Different OSs support different kinds of <code>file</code>s, see the OS
documentation for what kind of files are supported. Generally <em>regular</em>
files are supported by all OSs.</p>
<p>Additional documentation can be found in manual of the OS:</p>
<ul>
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendfile&amp;section=2">https://man.dragonflybsd.org/?command=sendfile&amp;section=2</a></li>
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendfile&amp;sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendfile&amp;sektion=2</a></li>
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendfile.2.html">https://man7.org/linux/man-pages/man2/sendfile.2.html</a></li>
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html</a> (archived, actually for iOS)</li>
<li>NetBSD: <a href="https://man.netbsd.org/sendfile.2">https://man.netbsd.org/sendfile.2</a></li>
<li>OpenBSD: <a href="https://man.openbsd.org/sendfile.2">https://man.openbsd.org/sendfile.2</a></li>
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html</a> (archived)</li>
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendfile">https://illumos.org/man/3SOCKET/sendfile</a></li>
</ul>
<p>The <code>offset</code> is the absolute offset into the <code>file</code> to use as starting
point.</p>
<p>Depending on the OS this function <em>may</em> change the offset of <code>file</code>. For
the best results reset the offset of the file before using it again.</p>
<p>The <code>length</code> determines how many bytes to send, where a length of <code>None</code>
means it will try to send all bytes.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.tclass_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2686-2691">source</a><h4 class="code-header">pub fn <a href="#method.tclass_v6" class="fn">tclass_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_TCLASS</code> option for this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tclass_v6" title="method socket2::Socket::set_tclass_v6"><code>set_tclass_v6</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tclass_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2726-2735">source</a><h4 class="code-header">pub fn <a href="#method.set_tclass_v6" class="fn">set_tclass_v6</a>(&amp;self, tclass: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_TCLASS</code> option for this socket.</p>
<p>Specifies the traffic class field that is used in every packets
sent from this socket.</p>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-AsFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3036-3041">source</a><a href="#impl-AsFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/trait.AsFd.html" title="trait std::os::fd::owned::AsFd">AsFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3037-3040">source</a><a href="#method.as_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/trait.AsFd.html#tymethod.as_fd" class="fn">as_fd</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/struct.BorrowedFd.html" title="struct std::os::fd::owned::BorrowedFd">BorrowedFd</a>&lt;'_&gt;</h4></section></summary><div class='docblock'>Borrows the file descriptor. <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/trait.AsFd.html#tymethod.as_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AsRawFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3044-3048">source</a><a href="#impl-AsRawFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.AsRawFd.html" title="trait std::os::fd::raw::AsRawFd">AsRawFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_raw_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3045-3047">source</a><a href="#method.as_raw_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd" class="fn">as_raw_fd</a>(&amp;self) -&gt; <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a></h4></section></summary><div class='docblock'>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2084-2092">source</a><a href="#impl-Debug-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2085-2091">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3COwnedFd%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3066-3071">source</a><a href="#impl-From%3COwnedFd%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a>&gt; for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3067-3070">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(fd: <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-OwnedFd" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3051-3056">source</a><a href="#impl-From%3CSocket%3E-for-OwnedFd" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-8" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3052-3055">source</a><a href="#method.from-8" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(sock: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-TcpListener" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2098">source</a><a href="#impl-From%3CSocket%3E-for-TcpListener" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-9" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2098">source</a><a href="#method.from-9" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-TcpStream" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2097">source</a><a href="#impl-From%3CSocket%3E-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-3" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2097">source</a><a href="#method.from-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a> <a href="#" class="tooltip" data-notable-ty="TcpStream"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UdpSocket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2099">source</a><a href="#impl-From%3CSocket%3E-for-UdpSocket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-10" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2099">source</a><a href="#method.from-10" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixDatagram" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3091">source</a><a href="#impl-From%3CSocket%3E-for-UnixDatagram" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-11" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3091">source</a><a href="#method.from-11" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixListener" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3089">source</a><a href="#impl-From%3CSocket%3E-for-UnixListener" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-4" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3089">source</a><a href="#method.from-4" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixStream" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3087">source</a><a href="#impl-From%3CSocket%3E-for-UnixStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-13" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3087">source</a><a href="#method.from-13" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CTcpListener%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2095">source</a><a href="#impl-From%3CTcpListener%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a>&gt; for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-12" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2095">source</a><a href="#method.from-12" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CTcpStream%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2094">source</a><a href="#impl-From%3CTcpStream%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>&gt; for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2094">source</a><a href="#method.from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUdpSocket%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2096">source</a><a href="#impl-From%3CUdpSocket%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a>&gt; for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2096">source</a><a href="#method.from-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUnixDatagram%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3085">source</a><a href="#impl-From%3CUnixDatagram%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a>&gt; for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-5" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3085">source</a><a href="#method.from-5" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUnixListener%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3083">source</a><a href="#impl-From%3CUnixListener%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a>&gt; for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-7" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3083">source</a><a href="#method.from-7" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUnixStream%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3081">source</a><a href="#impl-From%3CUnixStream%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a>&gt; for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-6" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3081">source</a><a href="#method.from-6" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-FromRawFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3074-3078">source</a><a href="#impl-FromRawFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.FromRawFd.html" title="trait std::os::fd::raw::FromRawFd">FromRawFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from_raw_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3075-3077">source</a><a href="#method.from_raw_fd" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.FromRawFd.html#tymethod.from_raw_fd" class="fn">from_raw_fd</a>(fd: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>) -&gt; <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket"></a></h4></section></summary><div class='docblock'>Constructs a new instance of <code>Self</code> from the given raw file
descriptor. <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.FromRawFd.html#tymethod.from_raw_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-IntoRawFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3059-3063">source</a><a href="#impl-IntoRawFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.IntoRawFd.html" title="trait std::os::fd::raw::IntoRawFd">IntoRawFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into_raw_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#3060-3062">source</a><a href="#method.into_raw_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.IntoRawFd.html#tymethod.into_raw_fd" class="fn">into_raw_fd</a>(self) -&gt; <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a></h4></section></summary><div class='docblock'>Consumes this object, returning the raw underlying file descriptor. <a href="https://doc.rust-lang.org/1.76.0/std/os/fd/raw/trait.IntoRawFd.html#tymethod.into_raw_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Read-for-%26Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2039-2052">source</a><a href="#impl-Read-for-%26Socket" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for &amp;'a <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.read-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2040-2044">source</a><a href="#method.read-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#tymethod.read" class="fn">read</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Pull some bytes from this source into the specified buffer, returning
how many bytes were read. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#tymethod.read">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_vectored-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2047-2051">source</a><a href="#method.read_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_vectored" class="fn">read_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Like <code>read</code>, except that it reads into a slice of buffers. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_read_vectored-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#768">source</a><a href="#method.is_read_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.is_read_vectored" class="fn">is_read_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Read</code>er has an efficient <code>read_vectored</code>
implementation. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.is_read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_end-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#819">source</a></span><a href="#method.read_to_end-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_end" class="fn">read_to_end</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Read all bytes until EOF in this source, placing them into <code>buf</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_end">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_string-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#862">source</a></span><a href="#method.read_to_string-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_string" class="fn">read_to_string</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Read all bytes until EOF in this source, appending them to <code>buf</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_string">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_exact-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.6.0">1.6.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#917">source</a></span><a href="#method.read_exact-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_exact" class="fn">read_exact</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Read the exact number of bytes required to fill <code>buf</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#928">source</a><a href="#method.read_buf-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf" class="fn">read_buf</a>(&amp;mut self, buf: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Pull some bytes from this source into the specified buffer. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf_exact-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#951">source</a><a href="#method.read_buf_exact-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf_exact" class="fn">read_buf_exact</a>(&amp;mut self, cursor: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Read the exact number of bytes required to fill <code>cursor</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1003-1005">source</a></span><a href="#method.by_ref-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.by_ref" class="fn">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&amp;mut Self</a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adaptor for this instance of <code>Read</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.by_ref">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.bytes-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1046-1048">source</a></span><a href="#method.bytes-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.bytes" class="fn">bytes</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a>&lt;Self&gt;<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Transforms this <code>Read</code> instance to an <a href="https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> over its bytes. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.bytes">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.chain-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1084-1086">source</a></span><a href="#method.chain-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.chain" class="fn">chain</a>&lt;R&gt;(self, next: R) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a>&lt;Self, R&gt;<div class="where">where
R: <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will chain this stream with another. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.chain">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.take-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1123-1125">source</a></span><a href="#method.take-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.take" class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u64.html">u64</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.Take.html" title="struct std::io::Take">Take</a>&lt;Self&gt;<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will read at most <code>limit</code> bytes from it. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.take">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Read-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2020-2037">source</a><a href="#impl-Read-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.read" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2021-2026">source</a><a href="#method.read" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#tymethod.read" class="fn">read</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Pull some bytes from this source into the specified buffer, returning
how many bytes were read. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#tymethod.read">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_vectored" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2029-2036">source</a><a href="#method.read_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_vectored" class="fn">read_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Like <code>read</code>, except that it reads into a slice of buffers. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_read_vectored" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#768">source</a><a href="#method.is_read_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.is_read_vectored" class="fn">is_read_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Read</code>er has an efficient <code>read_vectored</code>
implementation. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.is_read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_end" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#819">source</a></span><a href="#method.read_to_end" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_end" class="fn">read_to_end</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Read all bytes until EOF in this source, placing them into <code>buf</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_end">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_string" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#862">source</a></span><a href="#method.read_to_string" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_string" class="fn">read_to_string</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Read all bytes until EOF in this source, appending them to <code>buf</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_to_string">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_exact" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.6.0">1.6.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#917">source</a></span><a href="#method.read_exact" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_exact" class="fn">read_exact</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Read the exact number of bytes required to fill <code>buf</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#928">source</a><a href="#method.read_buf" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf" class="fn">read_buf</a>(&amp;mut self, buf: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Pull some bytes from this source into the specified buffer. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf_exact" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#951">source</a><a href="#method.read_buf_exact" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf_exact" class="fn">read_buf_exact</a>(&amp;mut self, cursor: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Read the exact number of bytes required to fill <code>cursor</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.read_buf_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1003-1005">source</a></span><a href="#method.by_ref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.by_ref" class="fn">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&amp;mut Self</a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adaptor for this instance of <code>Read</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.by_ref">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.bytes" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1046-1048">source</a></span><a href="#method.bytes" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.bytes" class="fn">bytes</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a>&lt;Self&gt;<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Transforms this <code>Read</code> instance to an <a href="https://doc.rust-lang.org/1.76.0/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> over its bytes. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.bytes">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.chain" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1084-1086">source</a></span><a href="#method.chain" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.chain" class="fn">chain</a>&lt;R&gt;(self, next: R) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a>&lt;Self, R&gt;<div class="where">where
R: <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will chain this stream with another. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.chain">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.take" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1123-1125">source</a></span><a href="#method.take" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.take" class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u64.html">u64</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.Take.html" title="struct std::io::Take">Take</a>&lt;Self&gt;<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will read at most <code>limit</code> bytes from it. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html#method.take">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Write-for-%26Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2069-2082">source</a><a href="#impl-Write-for-%26Socket" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for &amp;'a <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.write" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2070-2072">source</a><a href="#method.write" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.write" class="fn">write</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Write a buffer into this writer, returning how many bytes were written. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.write">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_vectored" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2075-2077">source</a><a href="#method.write_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_vectored" class="fn">write_vectored</a>(&amp;mut self, bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Like <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.write" title="method std::io::Write::write"><code>write</code></a>, except that it writes from a slice of buffers. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.flush" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2079-2081">source</a><a href="#method.flush" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.flush" class="fn">flush</a>(&amp;mut self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class='docblock'>Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.flush">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_write_vectored" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1606">source</a><a href="#method.is_write_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.is_write_vectored" class="fn">is_write_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Write</code>r has an efficient <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_vectored" title="method std::io::Write::write_vectored"><code>write_vectored</code></a>
implementation. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.is_write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1668">source</a></span><a href="#method.write_all" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all" class="fn">write_all</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Attempts to write an entire buffer into this writer. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all_vectored" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1733">source</a><a href="#method.write_all_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all_vectored" class="fn">write_all_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>write_all_vectored</code>)</span></div></span><div class='docblock'>Attempts to write multiple buffers into this writer. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_fmt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1789">source</a></span><a href="#method.write_fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_fmt" class="fn">write_fmt</a>(&amp;mut self, fmt: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Arguments.html" title="struct core::fmt::Arguments">Arguments</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Writes a formatted string into this writer, returning any error
encountered. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_fmt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref-2" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1845-1847">source</a></span><a href="#method.by_ref-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.by_ref" class="fn">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&amp;mut Self</a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adapter for this instance of <code>Write</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.by_ref">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Write-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2054-2067">source</a><a href="#impl-Write-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.write-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2055-2057">source</a><a href="#method.write-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.write" class="fn">write</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Write a buffer into this writer, returning how many bytes were written. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.write">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_vectored-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2060-2062">source</a><a href="#method.write_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_vectored" class="fn">write_vectored</a>(&amp;mut self, bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Like <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.write" title="method std::io::Write::write"><code>write</code></a>, except that it writes from a slice of buffers. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.flush-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2064-2066">source</a><a href="#method.flush-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.flush" class="fn">flush</a>(&amp;mut self) -&gt; <a class="type" href="https://doc.rust-lang.org/1.76.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class='docblock'>Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#tymethod.flush">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_write_vectored-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1606">source</a><a href="#method.is_write_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.is_write_vectored" class="fn">is_write_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Write</code>r has an efficient <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_vectored" title="method std::io::Write::write_vectored"><code>write_vectored</code></a>
implementation. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.is_write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1668">source</a></span><a href="#method.write_all-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all" class="fn">write_all</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Attempts to write an entire buffer into this writer. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all_vectored-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1733">source</a><a href="#method.write_all_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all_vectored" class="fn">write_all_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>write_all_vectored</code>)</span></div></span><div class='docblock'>Attempts to write multiple buffers into this writer. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_all_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_fmt-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1789">source</a></span><a href="#method.write_fmt-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_fmt" class="fn">write_fmt</a>(&amp;mut self, fmt: <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Arguments.html" title="struct core::fmt::Arguments">Arguments</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Writes a formatted string into this writer, returning any error
encountered. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.write_fmt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref-3" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/std/io/mod.rs.html#1845-1847">source</a></span><a href="#method.by_ref-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.by_ref" class="fn">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&amp;mut Self</a><div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adapter for this instance of <code>Write</code>. <a href="https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html#method.by_ref">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-Socket" class="impl"><a href="#impl-RefUnwindSafe-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-Send-for-Socket" class="impl"><a href="#impl-Send-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-Sync-for-Socket" class="impl"><a href="#impl-Sync-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-Unpin-for-Socket" class="impl"><a href="#impl-Unpin-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-UnwindSafe-for-Socket" class="impl"><a href="#impl-UnwindSafe-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#763">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-14" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#766">source</a><a href="#method.from-14" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#747-749">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#756">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#803-805">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#810">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#788-790">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#795">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div><script type="text/json" id="notable-traits-data">{"Socket":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl&lt;'a&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for &amp;'a <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl&lt;'a&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for &amp;'a <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div>","Socket":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl&lt;'a&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for &amp;'a <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl&lt;'a&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for &amp;'a <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div>","TcpStream":"<h3>Notable traits for <code>&amp;<a class=\"struct\" href=\"https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html\" title=\"struct std::net::tcp::TcpStream\">TcpStream</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for &amp;<a class=\"struct\" href=\"https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html\" title=\"struct std::net::tcp::TcpStream\">TcpStream</a></div><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for <a class=\"struct\" href=\"https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html\" title=\"struct std::net::tcp::TcpStream\">TcpStream</a></div><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for &amp;<a class=\"struct\" href=\"https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html\" title=\"struct std::net::tcp::TcpStream\">TcpStream</a></div><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.76.0/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"https://doc.rust-lang.org/1.76.0/std/net/tcp/struct.TcpStream.html\" title=\"struct std::net::tcp::TcpStream\">TcpStream</a></div>"}</script></section></div></main></body></html>