blob: 260c1bad662aa9b85f70fe356032bdb5a4d9d82f [file] [log] [blame]
<!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."><meta name="keywords" content="rust, rustlang, rust-lang, Socket"><title>Socket in socket2 - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.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><a class="sidebar-logo" href="../socket2/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../socket2/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Socket</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.accept">accept</a></li><li><a href="#method.accept4">accept4</a></li><li><a href="#method.accept_raw">accept_raw</a></li><li><a href="#method.attach_filter">attach_filter</a></li><li><a href="#method.bind">bind</a></li><li><a href="#method.bind_device">bind_device</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.cork">cork</a></li><li><a href="#method.cpu_affinity">cpu_affinity</a></li><li><a href="#method.detach_filter">detach_filter</a></li><li><a href="#method.device">device</a></li><li><a href="#method.domain">domain</a></li><li><a href="#method.freebind">freebind</a></li><li><a href="#method.freebind_ipv6">freebind_ipv6</a></li><li><a href="#method.header_included">header_included</a></li><li><a href="#method.ip_transparent">ip_transparent</a></li><li><a href="#method.is_listener">is_listener</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.mark">mark</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.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.protocol">protocol</a></li><li><a href="#method.quickack">quickack</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_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.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.set_broadcast">set_broadcast</a></li><li><a href="#method.set_cloexec">set_cloexec</a></li><li><a href="#method.set_cork">set_cork</a></li><li><a href="#method.set_cpu_affinity">set_cpu_affinity</a></li><li><a href="#method.set_freebind">set_freebind</a></li><li><a href="#method.set_freebind_ipv6">set_freebind_ipv6</a></li><li><a href="#method.set_header_included">set_header_included</a></li><li><a href="#method.set_ip_transparent">set_ip_transparent</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_mark">set_mark</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_quickack">set_quickack</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_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_tcp_keepalive">set_tcp_keepalive</a></li><li><a href="#method.set_tcp_user_timeout">set_tcp_user_timeout</a></li><li><a href="#method.set_thin_linear_timeouts">set_thin_linear_timeouts</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.tcp_user_timeout">tcp_user_timeout</a></li><li><a href="#method.thin_linear_timeouts">thin_linear_timeouts</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"><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%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-%26%27a%20Socket">Read</a></li><li><a href="#impl-Read-for-Socket">Read</a></li><li><a href="#impl-Write-for-%26%27a%20Socket">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"><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"><li><a href="#impl-Any-for-Socket">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-Socket">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-Socket">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-Socket">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-Socket">Into&lt;U&gt;</a></li><li><a href="#impl-TryFrom%3CU%3E-for-Socket">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-Socket">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In socket2</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="index.html">socket2</a>::<wbr><a class="struct" href="#">Socket</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/socket2/socket.rs.html#74-76">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct Socket { /* private fields */ }</code></pre></div><details class="rustdoc-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 what’s 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/nightly/std/net/tcp/struct.TcpStream.html"><code>TcpStream</code></a> or <a href="https://doc.rust-lang.org/nightly/std/net/udp/struct.UdpSocket.html"><code>UdpSocket</code></a>, using the
<a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="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
there options without overwriting previously set options. We do this by
first getting the current settings, applying the desired changes and than
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 bound to two addresses
</span><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>address: SocketAddr = <span class="string">&quot;[::1]:12345&quot;</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.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="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#81-690">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="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#129-132">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">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/nightly/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/nightly/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="Socket::new_raw"><code>Socket::new_raw</code></a> can be used if you don’t want these flags to be set.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new_raw" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#138-141">source</a><h4 class="code-header">pub fn <a href="#method.new_raw" class="fnname">new_raw</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;protocol: <a class="enum" href="https://doc.rust-lang.org/nightly/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;<br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.pair" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#151-161">source</a><h4 class="code-header">pub fn <a href="#method.pair" class="fnname">pair</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;protocol: <a class="enum" href="https://doc.rust-lang.org/nightly/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;<br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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="Socket::new"><code>Socket::new</code></a>,
<a href="struct.Socket.html#method.pair_raw" title="Socket::pair_raw"><code>Socket::pair_raw</code></a> can be used if you don’t want to set those flags.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.pair_raw" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#168-176">source</a><h4 class="code-header">pub fn <a href="#method.pair_raw" class="fnname">pair_raw</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;protocol: <a class="enum" href="https://doc.rust-lang.org/nightly/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;<br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.bind" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#182-184">source</a><h4 class="code-header">pub fn <a href="#method.bind" class="fnname">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/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.connect" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#200-202">source</a><h4 class="code-header">pub fn <a href="#method.connect" class="fnname">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/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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>
<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 can’t 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="rustdoc-toggle method-toggle" open><summary><section id="method.connect_timeout" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#223-237">source</a><h4 class="code-header">pub fn <a href="#method.connect_timeout" class="fnname">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/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.listen" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#247-249">source</a><h4 class="code-header">pub fn <a href="#method.listen" class="fnname">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/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="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>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.accept" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#258-292">source</a><h4 class="code-header">pub fn <a href="#method.accept" class="fnname">accept</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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="Socket::new"><code>Socket::new</code></a>,
<a href="struct.Socket.html#method.accept_raw" title="Socket::accept_raw"><code>Socket::accept_raw</code></a> can be used if you don’t want to set those flags.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.accept_raw" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#298-300">source</a><h4 class="code-header">pub fn <a href="#method.accept_raw" class="fnname">accept_raw</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.local_addr" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#310-312">source</a><h4 class="code-header">pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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>
<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">bound</a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peer_addr" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#321-323">source</a><h4 class="code-header">pub fn <a href="#method.peer_addr" class="fnname">peer_addr</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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>
<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"><code>connect</code>ed</a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#327-329">source</a><h4 class="code-header">pub fn <a href="#method.type" class="fnname">type</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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="Type"><code>Type</code></a> of this socket by checking the <code>SO_TYPE</code> option on
this socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_clone" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#344-346">source</a><h4 class="code-header">pub fn <a href="#method.try_clone" class="fnname">try_clone</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.set_nonblocking" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#356-358">source</a><h4 class="code-header">pub fn <a href="#method.set_nonblocking" class="fnname">set_nonblocking</a>(&amp;self, nonblocking: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Moves this TCP stream into or out of nonblocking mode.</p>
<h5 id="notes-5"><a href="#notes-5">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="rustdoc-toggle method-toggle" open><summary><section id="method.shutdown" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#364-366">source</a><h4 class="code-header">pub fn <a href="#method.shutdown" class="fnname">shutdown</a>(&amp;self, how: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/enum.Shutdown.html" title="enum std::net::Shutdown">Shutdown</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.recv" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#388-390">source</a><h4 class="code-header">pub fn <a href="#method.recv" class="fnname">recv</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>connect</code></a> method will connect this socket to a remote address.
This method might fail if the socket is not connected.</p>
<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/nightly/std/io/trait.Read.html#tymethod.read" title="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="rustdoc-toggle method-toggle" open><summary><section id="method.recv_out_of_band" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#399-401">source</a><h4 class="code-header">pub fn <a href="#method.recv_out_of_band" class="fnname">recv_out_of_band</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>recv</code></a>, <a href="struct.Socket.html#method.out_of_band_inline"><code>out_of_band_inline</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.recv_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#407-413">source</a><h4 class="code-header">pub fn <a href="#method.recv_with_flags" class="fnname">recv_with_flags</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.u8.html">u8</a>&gt;],<br>&nbsp;&nbsp;&nbsp;&nbsp;flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv"><code>recv</code></a> but allows for specification of arbitrary flags to
the underlying <code>recv</code> call.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.recv_vectored" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#442-447">source</a><h4 class="code-header">pub fn <a href="#method.recv_vectored" class="fnname">recv_vectored</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;]<br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>recv</code></a> this allows passing multiple buffers.</p>
<p>The <a href="struct.Socket.html#method.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="RecvFlags"><code>RecvFlags</code></a> for more information about
the returned flags.</p>
<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/nightly/std/io/trait.Read.html#method.read_vectored" title="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="rustdoc-toggle method-toggle" open><summary><section id="method.recv_vectored_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#462-468">source</a><h4 class="code-header">pub fn <a href="#method.recv_vectored_with_flags" class="fnname">recv_vectored_with_flags</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;],<br>&nbsp;&nbsp;&nbsp;&nbsp;flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><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"><code>recv_vectored</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peek" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#483-485">source</a><h4 class="code-header">pub fn <a href="#method.peek" class="fnname">peek</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>recv</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.recv_from" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#496-498">source</a><h4 class="code-header">pub fn <a href="#method.recv_from" class="fnname">recv_from</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/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>
<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"><code>recv</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.recv_from_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#504-510">source</a><h4 class="code-header">pub fn <a href="#method.recv_from_with_flags" class="fnname">recv_from_with_flags</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.u8.html">u8</a>&gt;],<br>&nbsp;&nbsp;&nbsp;&nbsp;flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>recv_from</code></a> but allows for specification of arbitrary
flags to the underlying <code>recvfrom</code> call.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.recv_from_vectored" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#526-531">source</a><h4 class="code-header">pub fn <a href="#method.recv_from_vectored" class="fnname">recv_from_vectored</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;]<br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/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="RecvFlags"><code>RecvFlags</code></a> and the remote address from the data is coming. Unlike
<a href="struct.Socket.html#method.recv_from"><code>recv_from</code></a> this allows passing multiple buffers.</p>
<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"><code>recv_vectored</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.recv_from_vectored_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#546-552">source</a><h4 class="code-header">pub fn <a href="#method.recv_from_vectored_with_flags" class="fnname">recv_from_vectored_with_flags</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;bufs: &amp;mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a>&lt;'_&gt;],<br>&nbsp;&nbsp;&nbsp;&nbsp;flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><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"><code>recv_vectored</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peek_from" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#583-585">source</a><h4 class="code-header">pub fn <a href="#method.peek_from" class="fnname">peek_from</a>(&amp;self, buf: &amp;mut [<a class="union" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.u8.html">u8</a>&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;(<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><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"><code>peek_sender</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.peek_sender" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#593-595">source</a><h4 class="code-header">pub fn <a href="#method.peek_sender" class="fnname">peek_sender</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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"><code>peek_from</code></a> with a zero-sized buffer,
but suppresses the <code>WSAEMSGSIZE</code> error on Windows.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#603-605">source</a><h4 class="code-header">pub fn <a href="#method.send" class="fnname">send</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#611-613">source</a><h4 class="code-header">pub fn <a href="#method.send_with_flags" class="fnname">send_with_flags</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="#method.send"><code>send</code></a> but allows for specification of arbitrary flags to the underlying
<code>send</code> call.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send_vectored" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#618-620">source</a><h4 class="code-header">pub fn <a href="#method.send_vectored" class="fnname">send_vectored</a>(&amp;self, bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.send_vectored_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#628-634">source</a><h4 class="code-header">pub fn <a href="#method.send_vectored_with_flags" class="fnname">send_vectored_with_flags</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;],<br>&nbsp;&nbsp;&nbsp;&nbsp;flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.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>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send_out_of_band" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#643-645">source</a><h4 class="code-header">pub fn <a href="#method.send_out_of_band" class="fnname">send_out_of_band</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="#method.send"><code>send</code></a>, <a href="#method.out_of_band_inline"><code>out_of_band_inline</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send_to" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#651-653">source</a><h4 class="code-header">pub fn <a href="#method.send_to" class="fnname">send_to</a>(&amp;self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send_to_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#659-666">source</a><h4 class="code-header">pub fn <a href="#method.send_to_with_flags" class="fnname">send_to_with_flags</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>],<br>&nbsp;&nbsp;&nbsp;&nbsp;addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.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="rustdoc-toggle method-toggle" open><summary><section id="method.send_to_vectored" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#672-674">source</a><h4 class="code-header">pub fn <a href="#method.send_to_vectored" class="fnname">send_to_vectored</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;],<br>&nbsp;&nbsp;&nbsp;&nbsp;addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send_to_vectored_with_flags" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#682-689">source</a><h4 class="code-header">pub fn <a href="#method.send_to_vectored_with_flags" class="fnname">send_to_vectored_with_flags</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;],<br>&nbsp;&nbsp;&nbsp;&nbsp;addr: &amp;<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><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></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Socket-1" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#767-1011">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="rustdoc-toggle method-toggle" open><summary><section id="method.broadcast" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#773-778">source</a><h4 class="code-header">pub fn <a href="#method.broadcast" class="fnname">broadcast</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_broadcast</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_broadcast" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#784-793">source</a><h4 class="code-header">pub fn <a href="#method.set_broadcast" class="fnname">set_broadcast</a>(&amp;self, broadcast: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.take_error" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#800-806">source</a><h4 class="code-header">pub fn <a href="#method.take_error" class="fnname">take_error</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.keepalive" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#813-818">source</a><h4 class="code-header">pub fn <a href="#method.keepalive" class="fnname">keepalive</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_keepalive</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_keepalive" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#823-832">source</a><h4 class="code-header">pub fn <a href="#method.set_keepalive" class="fnname">set_keepalive</a>(&amp;self, keepalive: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.linger" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#839-844">source</a><h4 class="code-header">pub fn <a href="#method.linger" class="fnname">linger</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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"><code>set_linger</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_linger" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#860-863">source</a><h4 class="code-header">pub fn <a href="#method.set_linger" class="fnname">set_linger</a>(&amp;self, linger: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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-6"><a href="#notes-6">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="rustdoc-toggle method-toggle" open><summary><section id="method.out_of_band_inline" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#872-877">source</a><h4 class="code-header">pub fn <a href="#method.out_of_band_inline" class="fnname">out_of_band_inline</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_out_of_band_inline</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_out_of_band_inline" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#887-896">source</a><h4 class="code-header">pub fn <a href="#method.set_out_of_band_inline" class="fnname">set_out_of_band_inline</a>(&amp;self, oob_inline: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.recv_buffer_size" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#903-908">source</a><h4 class="code-header">pub fn <a href="#method.recv_buffer_size" class="fnname">recv_buffer_size</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_recv_buffer_size</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_recv_buffer_size" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#914-923">source</a><h4 class="code-header">pub fn <a href="#method.set_recv_buffer_size" class="fnname">set_recv_buffer_size</a>(&amp;self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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 system’s receive buffer associated
with the socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_timeout" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#929-931">source</a><h4 class="code-header">pub fn <a href="#method.read_timeout" class="fnname">read_timeout</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.set_read_timeout" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#937-939">source</a><h4 class="code-header">pub fn <a href="#method.set_read_timeout" class="fnname">set_read_timeout</a>(&amp;self, duration: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.reuse_address" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#946-951">source</a><h4 class="code-header">pub fn <a href="#method.reuse_address" class="fnname">reuse_address</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_reuse_address</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_reuse_address" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#958-967">source</a><h4 class="code-header">pub fn <a href="#method.set_reuse_address" class="fnname">set_reuse_address</a>(&amp;self, reuse: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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
there’s a socket already listening on this port.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.send_buffer_size" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#974-979">source</a><h4 class="code-header">pub fn <a href="#method.send_buffer_size" class="fnname">send_buffer_size</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_send_buffer_size</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_send_buffer_size" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#985-994">source</a><h4 class="code-header">pub fn <a href="#method.set_send_buffer_size" class="fnname">set_send_buffer_size</a>(&amp;self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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 system’s send buffer associated with
the socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_timeout" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1000-1002">source</a><h4 class="code-header">pub fn <a href="#method.write_timeout" class="fnname">write_timeout</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.set_write_timeout" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1008-1010">source</a><h4 class="code-header">pub fn <a href="#method.set_write_timeout" class="fnname">set_write_timeout</a>(&amp;self, duration: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Socket-2" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1039-1478">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="rustdoc-toggle method-toggle" open><summary><section id="method.header_included" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1047-1052">source</a><h4 class="code-header">pub fn <a href="#method.header_included" class="fnname">header_included</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_header_included</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_header_included" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1067-1076">source</a><h4 class="code-header">pub fn <a href="#method.set_header_included" class="fnname">set_header_included</a>(&amp;self, included: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><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"><code>IP_TTL</code></a>,
and <a href="struct.Socket.html#method.set_tos"><code>IP_TOS</code></a> are ignored.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ip_transparent" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1085-1090">source</a><h4 class="code-header">pub fn <a href="#method.ip_transparent" class="fnname">ip_transparent</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_TRANSPARENT</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_ip_transparent"><code>set_ip_transparent</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_ip_transparent" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1109-1118">source</a><h4 class="code-header">pub fn <a href="#method.set_ip_transparent" class="fnname">set_ip_transparent</a>(&amp;self, transparent: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_TRANSPARENT</code> option on this socket.</p>
<p>Setting this boolean option enables transparent proxying
on this socket. This socket option allows the calling
application to bind to a nonlocal IP address and operate
both as a client and a server with the foreign address as
the local endpoint. NOTE: this requires that routing be
set up in a way that packets going to the foreign address
are routed through the TProxy box (i.e., the system
hosting the application that employs the IP_TRANSPARENT
socket option). Enabling this socket option requires
superuser privileges (the <code>CAP_NET_ADMIN</code> capability).</p>
<p>TProxy redirection with the iptables TPROXY target also
requires that this option be set on the redirected socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.join_multicast_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1127-1133">source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v4" class="fnname">join_multicast_v4</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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 it’s <a href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED" title="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="rustdoc-toggle method-toggle" open><summary><section id="method.leave_multicast_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1140-1153">source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v4" class="fnname">leave_multicast_v4</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>join_multicast_v4</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.join_multicast_v4_n" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1170-1184">source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v4_n" class="fnname">join_multicast_v4_n</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: &amp;<a class="enum" href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress">InterfaceIndexOrAddress</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="InterfaceIndexOrAddress"><code>InterfaceIndexOrAddress</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.leave_multicast_v4_n" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1200-1214">source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v4_n" class="fnname">leave_multicast_v4_n</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: &amp;<a class="enum" href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress">InterfaceIndexOrAddress</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>join_multicast_v4_n</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.join_ssm_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1232-1251">source</a><h4 class="code-header">pub fn <a href="#method.join_ssm_v4" class="fnname">join_ssm_v4</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;source: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;group: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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 it’s <a href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED" title="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="rustdoc-toggle method-toggle" open><summary><section id="method.leave_ssm_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1267-1286">source</a><h4 class="code-header">pub fn <a href="#method.leave_ssm_v4" class="fnname">leave_ssm_v4</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;source: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;group: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>join_ssm_v4</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.multicast_if_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1293-1297">source</a><h4 class="code-header">pub fn <a href="#method.multicast_if_v4" class="fnname">multicast_if_v4</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::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"><code>set_multicast_if_v4</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_multicast_if_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1302-1312">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_if_v4" class="fnname">set_multicast_if_v4</a>(&amp;self, interface: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv4Addr.html" title="struct std::net::ip_addr::Ipv4Addr">Ipv4Addr</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.multicast_loop_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1319-1324">source</a><h4 class="code-header">pub fn <a href="#method.multicast_loop_v4" class="fnname">multicast_loop_v4</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_multicast_loop_v4</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_multicast_loop_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1330-1339">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_loop_v4" class="fnname">set_multicast_loop_v4</a>(&amp;self, loop_v4: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.multicast_ttl_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1346-1351">source</a><h4 class="code-header">pub fn <a href="#method.multicast_ttl_v4" class="fnname">multicast_ttl_v4</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_multicast_ttl_v4</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_multicast_ttl_v4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1360-1369">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_ttl_v4" class="fnname">set_multicast_ttl_v4</a>(&amp;self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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
don’t 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="rustdoc-toggle method-toggle" open><summary><section id="method.ttl" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1376-1380">source</a><h4 class="code-header">pub fn <a href="#method.ttl" class="fnname">ttl</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_ttl</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_ttl" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1386-1388">source</a><h4 class="code-header">pub fn <a href="#method.set_ttl" class="fnname">set_ttl</a>(&amp;self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.set_tos" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1403-1405">source</a><h4 class="code-header">pub fn <a href="#method.set_tos" class="fnname">set_tos</a>(&amp;self, tos: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.tos" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1421-1425">source</a><h4 class="code-header">pub fn <a href="#method.tos" class="fnname">tos</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><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="rustdoc-toggle method-toggle" open><summary><section id="method.set_recv_tos" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1443-1454">source</a><h4 class="code-header">pub fn <a href="#method.set_recv_tos" class="fnname">set_recv_tos</a>(&amp;self, recv_tos: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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 IP_TOS 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="rustdoc-toggle method-toggle" open><summary><section id="method.recv_tos" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1472-1477">source</a><h4 class="code-header">pub fn <a href="#method.recv_tos" class="fnname">recv_tos</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_recv_tos</code></a>.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Socket-3" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1485-1671">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="rustdoc-toggle method-toggle" open><summary><section id="method.join_multicast_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1494-1508">source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v6" class="fnname">join_multicast_v6</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv6Addr.html" title="struct std::net::ip_addr::Ipv6Addr">Ipv6Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.leave_multicast_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1518-1532">source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v6" class="fnname">leave_multicast_v6</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;multiaddr: &amp;<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip_addr/struct.Ipv6Addr.html" title="struct std::net::ip_addr::Ipv6Addr">Ipv6Addr</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>join_multicast_v6</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.multicast_hops_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1539-1544">source</a><h4 class="code-header">pub fn <a href="#method.multicast_hops_v6" class="fnname">multicast_hops_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_multicast_hops_v6</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_multicast_hops_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1551-1560">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_hops_v6" class="fnname">set_multicast_hops_v6</a>(&amp;self, hops: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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
don’t leave the local network unless explicitly requested.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.multicast_if_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1567-1572">source</a><h4 class="code-header">pub fn <a href="#method.multicast_if_v6" class="fnname">multicast_if_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_multicast_if_v6</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_multicast_if_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1579-1588">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_if_v6" class="fnname">set_multicast_if_v6</a>(&amp;self, interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.multicast_loop_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1595-1600">source</a><h4 class="code-header">pub fn <a href="#method.multicast_loop_v6" class="fnname">multicast_loop_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_multicast_loop_v6</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_multicast_loop_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1606-1615">source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_loop_v6" class="fnname">set_multicast_loop_v6</a>(&amp;self, loop_v6: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.unicast_hops_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1620-1625">source</a><h4 class="code-header">pub fn <a href="#method.unicast_hops_v6" class="fnname">unicast_hops_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.set_unicast_hops_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1630-1639">source</a><h4 class="code-header">pub fn <a href="#method.set_unicast_hops_v6" class="fnname">set_unicast_hops_v6</a>(&amp;self, hops: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.only_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1646-1651">source</a><h4 class="code-header">pub fn <a href="#method.only_v6" class="fnname">only_v6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_only_v6</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_only_v6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1661-1670">source</a><h4 class="code-header">pub fn <a href="#method.set_only_v6" class="fnname">set_only_v6</a>(&amp;self, only_v6: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Socket-4" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1678-1857">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="rustdoc-toggle method-toggle" open><summary><section id="method.keepalive_time" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1697-1699">source</a><h4 class="code-header">pub fn <a href="#method.keepalive_time" class="fnname">keepalive_time</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.keepalive_interval" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1736-1741">source</a><h4 class="code-header">pub fn <a href="#method.keepalive_interval" class="fnname">keepalive_interval</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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"><code>set_tcp_keepalive</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.keepalive_retries" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1778-1783">source</a><h4 class="code-header">pub fn <a href="#method.keepalive_retries" class="fnname">keepalive_retries</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_tcp_keepalive</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_tcp_keepalive" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1823-1826">source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_keepalive" class="fnname">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/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="TcpKeepalive"><code>TcpKeepalive</code></a> struct. At a minimum, all systems
support configuring the <a href="struct.TcpKeepalive.html#method.with_time">keepalive time</a>: the time after which the OS
will start sending keepalive messages on an idle connection.</p>
<h5 id="notes-7"><a href="#notes-7">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="rustdoc-toggle method-toggle" open><summary><section id="method.nodelay" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1833-1838">source</a><h4 class="code-header">pub fn <a href="#method.nodelay" class="fnname">nodelay</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_nodelay</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_nodelay" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1847-1856">source</a><h4 class="code-header">pub fn <a href="#method.set_nodelay" class="fnname">set_nodelay</a>(&amp;self, nodelay: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Socket-5" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1079-2042">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="rustdoc-toggle method-toggle" open><summary><section id="method.accept4" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1116-1118">source</a><h4 class="code-header">pub fn <a href="#method.accept4" class="fnname">accept4</a>(&amp;self, 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/nightly/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>accept4(2)</code> function.</p>
<p>This function will block the calling thread until a new connection is
established. When established, the corresponding <code>Socket</code> and the remote
peer’s address will be returned.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_cloexec" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1147-1149">source</a><h4 class="code-header">pub fn <a href="#method.set_cloexec" class="fnname">set_cloexec</a>(&amp;self, close_on_exec: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets <code>CLOEXEC</code> on the socket.</p>
<h5 id="notes-8"><a href="#notes-8">Notes</a></h5>
<p>On supported platforms you can use <a href="struct.Type.html#method.cloexec" title="Type::cloexec"><code>Type::cloexec</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_nosigpipe" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1172-1174">source</a><h4 class="code-header">pub fn <a href="#method.set_nosigpipe" class="fnname">set_nosigpipe</a>(&amp;self, nosigpipe: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.mss" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1195-1200">source</a><h4 class="code-header">pub fn <a href="#method.mss" class="fnname">mss</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_mss</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_mss" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1208-1217">source</a><h4 class="code-header">pub fn <a href="#method.set_mss" class="fnname">set_mss</a>(&amp;self, mss: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.is_listener" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1242-1247">source</a><h4 class="code-header">pub fn <a href="#method.is_listener" class="fnname">is_listener</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Returns <code>true</code> if <code>listen(2)</code> was called on this socket by checking the
<code>SO_ACCEPTCONN</code> option on this socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.domain" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1271-1273">source</a><h4 class="code-header">pub fn <a href="#method.domain" class="fnname">domain</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the <a href="struct.Domain.html" title="Domain"><code>Domain</code></a> of this socket by checking the <code>SO_DOMAIN</code> option
on this socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.protocol" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1298-1306">source</a><h4 class="code-header">pub fn <a href="#method.protocol" class="fnname">protocol</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/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;</h4></section></summary><div class="docblock"><p>Returns the <a href="struct.Protocol.html" title="Protocol"><code>Protocol</code></a> of this socket by checking the <code>SO_PROTOCOL</code>
option on this socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.mark" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1325-1330">source</a><h4 class="code-header">pub fn <a href="#method.mark" class="fnname">mark</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>&gt;</h4></section></summary><div class="docblock"><p>Gets the value for the <code>SO_MARK</code> option on this socket.</p>
<p>This value gets the socket mark field for each packet sent through
this socket.</p>
<p>On Linux this function requires the <code>CAP_NET_ADMIN</code> capability.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_mark" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1350-1359">source</a><h4 class="code-header">pub fn <a href="#method.set_mark" class="fnname">set_mark</a>(&amp;self, mark: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets the value for the <code>SO_MARK</code> option on this socket.</p>
<p>This value sets the socket mark field for each packet sent through
this socket. Changing the mark can be used for mark-based routing
without netfilter or for packet filtering.</p>
<p>On Linux this function requires the <code>CAP_NET_ADMIN</code> capability.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cork" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1377-1382">source</a><h4 class="code-header">pub fn <a href="#method.cork" class="fnname">cork</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_CORK</code> option on this socket.</p>
<p>For more information about this option, see <a href="Socket::set_cork"><code>set_cork</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_cork" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1401-1410">source</a><h4 class="code-header">pub fn <a href="#method.set_cork" class="fnname">set_cork</a>(&amp;self, cork: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_CORK</code> option on this socket.</p>
<p>If set, don’t send out partial frames. All queued partial frames are
sent when the option is cleared again. There is a 200 millisecond ceiling on
the time for which output is corked by <code>TCP_CORK</code>. If this ceiling is reached,
then queued data is automatically transmitted.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.quickack" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1428-1433">source</a><h4 class="code-header">pub fn <a href="#method.quickack" class="fnname">quickack</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_QUICKACK</code> option on this socket.</p>
<p>For more information about this option, see <a href="Socket::set_quickack"><code>set_quickack</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_quickack" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1452-1461">source</a><h4 class="code-header">pub fn <a href="#method.set_quickack" class="fnname">set_quickack</a>(&amp;self, quickack: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_QUICKACK</code> option on this socket.</p>
<p>If set, acks are sent immediately, rather than delayed if needed in accordance to normal
TCP operation. This flag is not permanent, it only enables a switch to or from quickack mode.
Subsequent operation of the TCP protocol will once again enter/leave quickack mode depending on
internal protocol processing and factors such as delayed ack timeouts occurring and data transfer.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.thin_linear_timeouts" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1479-1488">source</a><h4 class="code-header">pub fn <a href="#method.thin_linear_timeouts" class="fnname">thin_linear_timeouts</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_THIN_LINEAR_TIMEOUTS</code> option on this socket.</p>
<p>For more information about this option, see <a href="Socket::set_thin_linear_timeouts"><code>set_thin_linear_timeouts</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_thin_linear_timeouts" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1506-1515">source</a><h4 class="code-header">pub fn <a href="#method.set_thin_linear_timeouts" class="fnname">set_thin_linear_timeouts</a>(&amp;self, timeouts: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_THIN_LINEAR_TIMEOUTS</code> option on this socket.</p>
<p>If set, the kernel will dynamically detect a thin-stream connection if there are less than four packets in flight.
With less than four packets in flight the normal TCP fast retransmission will not be effective.
The kernel will modify the retransmission to avoid the very high latencies that thin stream suffer because of exponential backoff.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.device" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1531-1550">source</a><h4 class="code-header">pub fn <a href="#method.device" class="fnname">device</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;&gt;&gt;</h4></section></summary><div class="docblock"><p>Gets the value for the <code>SO_BINDTODEVICE</code> option on this socket.</p>
<p>This value gets the socket binded device’s interface name.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.bind_device" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1570-1584">source</a><h4 class="code-header">pub fn <a href="#method.bind_device" class="fnname">bind_device</a>(&amp;self, interface: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sets the value for the <code>SO_BINDTODEVICE</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. Note that this only
works for some socket types, particularly <code>AF_INET</code> sockets.</p>
<p>If <code>interface</code> is <code>None</code> or an empty string it removes the binding.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cpu_affinity" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1639-1644">source</a><h4 class="code-header">pub fn <a href="#method.cpu_affinity" class="fnname">cpu_affinity</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_INCOMING_CPU</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_cpu_affinity"><code>set_cpu_affinity</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_cpu_affinity" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1651-1660">source</a><h4 class="code-header">pub fn <a href="#method.set_cpu_affinity" class="fnname">set_cpu_affinity</a>(&amp;self, cpu: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>SO_INCOMING_CPU</code> option on this socket.</p>
<p>Sets the CPU affinity of the socket.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.reuse_port" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1679-1684">source</a><h4 class="code-header">pub fn <a href="#method.reuse_port" class="fnname">reuse_port</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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"><code>set_reuse_port</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_reuse_port" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1703-1712">source</a><h4 class="code-header">pub fn <a href="#method.set_reuse_port" class="fnname">set_reuse_port</a>(&amp;self, reuse: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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
there’s a socket already listening on this port.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.freebind" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1730-1735">source</a><h4 class="code-header">pub fn <a href="#method.freebind" class="fnname">freebind</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_FREEBIND</code> option on this socket.</p>
<p>For more information about this option, see <a href="struct.Socket.html#method.set_freebind"><code>set_freebind</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_freebind" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1755-1764">source</a><h4 class="code-header">pub fn <a href="#method.set_freebind" class="fnname">set_freebind</a>(&amp;self, freebind: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>IP_FREEBIND</code> option on this socket.</p>
<p>If enabled, this boolean option allows binding to an IP address that is
nonlocal or does not (yet) exist. This permits listening on a socket,
without requiring the underlying network interface or the specified
dynamic IP address to be up at the time that the application is trying
to bind to it.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.freebind_ipv6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1778-1783">source</a><h4 class="code-header">pub fn <a href="#method.freebind_ipv6" class="fnname">freebind_ipv6</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>&gt;</h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_FREEBIND</code> option on this socket.</p>
<p>This is an IPv6 counterpart of <code>IP_FREEBIND</code> socket option on
Android/Linux. For more information about this option, see
<a href="struct.Socket.html#method.set_freebind"><code>set_freebind</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_freebind_ipv6" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1820-1829">source</a><h4 class="code-header">pub fn <a href="#method.set_freebind_ipv6" class="fnname">set_freebind_ipv6</a>(&amp;self, freebind: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set value for the <code>IPV6_FREEBIND</code> option on this socket.</p>
<p>This is an IPv6 counterpart of <code>IP_FREEBIND</code> socket option on
Android/Linux. For more information about this option, see
<a href="struct.Socket.html#method.set_freebind"><code>set_freebind</code></a>.</p>
<h5 id="examples-2"><a href="#examples-2">Examples</a></h5>
<p>On Linux:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>socket2::{Domain, Socket, Type};
<span class="kw">use </span>std::io::{<span class="self">self</span>, Error, ErrorKind};
<span class="kw">fn </span>enable_freebind(socket: <span class="kw-2">&amp;</span>Socket) -&gt; io::Result&lt;()&gt; {
<span class="kw">match </span>socket.domain()<span class="question-mark">? </span>{
Domain::IPV4 =&gt; socket.set_freebind(<span class="bool-val">true</span>)<span class="question-mark">?</span>,
Domain::IPV6 =&gt; socket.set_freebind_ipv6(<span class="bool-val">true</span>)<span class="question-mark">?</span>,
<span class="kw">_ </span>=&gt; <span class="kw">return </span><span class="prelude-val">Err</span>(Error::new(ErrorKind::Other, <span class="string">&quot;unsupported domain&quot;</span>)),
};
<span class="prelude-val">Ok</span>(())
}
</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.sendfile" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1870-1880">source</a><h4 class="code-header">pub fn <a href="#method.sendfile" class="fnname">sendfile</a>&lt;F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self,<br>&nbsp;&nbsp;&nbsp;&nbsp;file: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>F,<br>&nbsp;&nbsp;&nbsp;&nbsp;offset: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;length: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/num/nonzero/struct.NonZeroUsize.html" title="struct core::num::nonzero::NonZeroUsize">NonZeroUsize</a>&gt;<br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/std/os/fd/raw/trait.AsRawFd.html" title="trait std::os::fd::raw::AsRawFd">AsRawFd</a>,</span></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>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="rustdoc-toggle method-toggle" open><summary><section id="method.set_tcp_user_timeout" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1969-1981">source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_user_timeout" class="fnname">set_tcp_user_timeout</a>(&amp;self, timeout: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_USER_TIMEOUT</code> option on this socket.</p>
<p>If set, this specifies the maximum amount of time that transmitted data may remain
unacknowledged or buffered data may remain untransmitted before TCP will forcibly close the
corresponding connection.</p>
<p>Setting <code>timeout</code> to <code>None</code> or a zero duration causes the system default timeouts to
be used. If <code>timeout</code> in milliseconds is larger than <code>c_uint::MAX</code>, the timeout is clamped
to <code>c_uint::MAX</code>. For example, when <code>c_uint</code> is a 32-bit value, this limits the timeout to
approximately 49.71 days.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.tcp_user_timeout" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#1999-2010">source</a><h4 class="code-header">pub fn <a href="#method.tcp_user_timeout" class="fnname">tcp_user_timeout</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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>TCP_USER_TIMEOUT</code> option on this socket.</p>
<p>For more information about this option, see <a href="Socket::set_tcp_user_timeout"><code>set_tcp_user_timeout</code></a>.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.attach_filter" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2019-2033">source</a><h4 class="code-header">pub fn <a href="#method.attach_filter" class="fnname">attach_filter</a>(&amp;self, filters: &amp;[<a class="struct" href="../libc/unix/linux_like/linux/struct.sock_filter.html" title="struct libc::unix::linux_like::linux::sock_filter">sock_filter</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Attach Berkeley Packet Filter(BPF) on this socket.</p>
<p>BPF allows a user-space program to attach a filter onto any socket
and allow or disallow certain types of data to come through the socket.</p>
<p>For more information about this option, see <a href="https://www.kernel.org/doc/html/v5.12/networking/filter.html">filter</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.detach_filter" class="method has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2039-2041">source</a><h4 class="code-header">pub fn <a href="#method.detach_filter" class="fnname">detach_filter</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Detach Berkeley Packet Filter(BPF) from this socket.</p>
<p>For more information about this option, see [<code>attach_filter</code>]</p>
</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AsRawFd-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2045-2049">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.as_raw_fd" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2046-2048">source</a><a href="#method.as_raw_fd" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd" class="fnname">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/nightly/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1923-1931">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1924-1930">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/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/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-TcpListener" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1937">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/nightly/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/nightly/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-4" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1937">source</a><a href="#method.from-4" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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/nightly/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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-TcpStream" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1936">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/nightly/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/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-3" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1936">source</a><a href="#method.from-3" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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/nightly/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UdpSocket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1938">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/nightly/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/nightly/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-5" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1938">source</a><a href="#method.from-5" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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/nightly/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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixDatagram" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2076">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/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-11" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2076">source</a><a href="#method.from-11" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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/nightly/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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixListener" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2074">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/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-10" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2074">source</a><a href="#method.from-10" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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/nightly/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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixStream" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2072">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/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-9" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2072">source</a><a href="#method.from-9" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">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/nightly/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="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CTcpListener%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1934">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/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1934">source</a><a href="#method.from-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/nightly/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><span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></span><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span></code></span></span></span></span></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CTcpStream%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1933">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/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1933">source</a><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/nightly/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><span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></span><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span></code></span></span></span></span></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CUdpSocket%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1935">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/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1935">source</a><a href="#method.from-2" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/nightly/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><span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></span><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span></code></span></span></span></span></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CUnixDatagram%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2070">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/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-8" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2070">source</a><a href="#method.from-8" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/nightly/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><span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></span><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span></code></span></span></span></span></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CUnixListener%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2068">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/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-7" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2068">source</a><a href="#method.from-7" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/nightly/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><span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></span><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span></code></span></span></span></span></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CUnixStream%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2066">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/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-6" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2066">source</a><a href="#method.from-6" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/nightly/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><span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></span><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span></code></span></span></span></span></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-FromRawFd-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2059-2063">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from_raw_fd" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2060-2062">source</a><a href="#method.from_raw_fd" class="anchor"></a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/nightly/std/os/fd/raw/trait.FromRawFd.html#tymethod.from_raw_fd" class="fnname">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><span class="notable-traits"><span class="notable-traits-tooltip"><span class="notable-traits-tooltiptext"><span class="docblock"><span class="notable">Notable traits for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></span><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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></span><span class="where fmt-newline">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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></span></code></span></span></span></span></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/nightly/std/os/fd/raw/trait.FromRawFd.html#tymethod.from_raw_fd">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-IntoRawFd-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2052-2056">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.into_raw_fd" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/sys/unix.rs.html#2053-2055">source</a><a href="#method.into_raw_fd" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/os/fd/raw/trait.IntoRawFd.html#tymethod.into_raw_fd" class="fnname">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/nightly/std/os/fd/raw/trait.IntoRawFd.html#tymethod.into_raw_fd">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Read-for-%26%27a%20Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1878-1891">source</a><a href="#impl-Read-for-%26%27a%20Socket" class="anchor"></a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.read-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1879-1883">source</a><a href="#method.read-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read" class="fnname">read</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#tymethod.read">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_vectored-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1886-1890">source</a><a href="#method.read_vectored-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_vectored" class="fnname">read_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_read_vectored-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#658">source</a><a href="#method.is_read_vectored-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.is_read_vectored" class="fnname">is_read_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.is_read_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_to_end-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#709">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/nightly/std/io/trait.Read.html#method.read_to_end" class="fnname">read_to_end</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_to_end">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_to_string-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#752">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/nightly/std/io/trait.Read.html#method.read_to_string" class="fnname">read_to_string</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_to_string">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_exact-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.6.0">1.6.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#807">source</a></span><a href="#method.read_exact-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_exact" class="fnname">read_exact</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_exact">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_buf-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#818">source</a><a href="#method.read_buf-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_buf" class="fnname">read_buf</a>(&amp;mut self, buf: <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/readbuf/struct.BorrowedCursor.html" title="struct std::io::readbuf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_buf">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_buf_exact-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#827">source</a><a href="#method.read_buf_exact-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_buf_exact" class="fnname">read_buf_exact</a>(&amp;mut self, cursor: <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/readbuf/struct.BorrowedCursor.html" title="struct std::io::readbuf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_buf_exact">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.by_ref-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#879-881">source</a></span><a href="#method.by_ref-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.by_ref" class="fnname">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</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/nightly/std/io/trait.Read.html#method.by_ref">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.bytes-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#922-924">source</a></span><a href="#method.bytes-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.bytes" class="fnname">bytes</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a>&lt;Self&gt;</h4></section></summary><div class='docblock'>Transforms this <code>Read</code> instance to an <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="Iterator"><code>Iterator</code></a> over its bytes. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.bytes">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.chain-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#960-962">source</a></span><a href="#method.chain-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.chain" class="fnname">chain</a>&lt;R&gt;(self, next: R) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a>&lt;Self, R&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,</span></h4></section></summary><div class='docblock'>Creates an adapter which will chain this stream with another. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.chain">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.take-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#999-1001">source</a></span><a href="#method.take-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.take" class="fnname">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Take.html" title="struct std::io::Take">Take</a>&lt;Self&gt;</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/nightly/std/io/trait.Read.html#method.take">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Read-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1859-1876">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.read" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1860-1865">source</a><a href="#method.read" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read" class="fnname">read</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#tymethod.read">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_vectored" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1868-1875">source</a><a href="#method.read_vectored" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_vectored" class="fnname">read_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_read_vectored" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#658">source</a><a href="#method.is_read_vectored" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.is_read_vectored" class="fnname">is_read_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.is_read_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_to_end" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#709">source</a></span><a href="#method.read_to_end" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_to_end" class="fnname">read_to_end</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/alloc/struct.Global.html" title="struct alloc::alloc::Global">Global</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_to_end">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_to_string" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#752">source</a></span><a href="#method.read_to_string" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_to_string" class="fnname">read_to_string</a>(&amp;mut self, buf: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_to_string">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_exact" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.6.0">1.6.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#807">source</a></span><a href="#method.read_exact" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_exact" class="fnname">read_exact</a>(&amp;mut self, buf: &amp;mut [<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_exact">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_buf" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#818">source</a><a href="#method.read_buf" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_buf" class="fnname">read_buf</a>(&amp;mut self, buf: <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/readbuf/struct.BorrowedCursor.html" title="struct std::io::readbuf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_buf">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.read_buf_exact" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#827">source</a><a href="#method.read_buf_exact" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_buf_exact" class="fnname">read_buf_exact</a>(&amp;mut self, cursor: <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/readbuf/struct.BorrowedCursor.html" title="struct std::io::readbuf::BorrowedCursor">BorrowedCursor</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Read.html#method.read_buf_exact">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.by_ref" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#879-881">source</a></span><a href="#method.by_ref" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.by_ref" class="fnname">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</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/nightly/std/io/trait.Read.html#method.by_ref">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.bytes" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#922-924">source</a></span><a href="#method.bytes" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.bytes" class="fnname">bytes</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a>&lt;Self&gt;</h4></section></summary><div class='docblock'>Transforms this <code>Read</code> instance to an <a href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="Iterator"><code>Iterator</code></a> over its bytes. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.bytes">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.chain" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#960-962">source</a></span><a href="#method.chain" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.chain" class="fnname">chain</a>&lt;R&gt;(self, next: R) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a>&lt;Self, R&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,</span></h4></section></summary><div class='docblock'>Creates an adapter which will chain this stream with another. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.chain">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.take" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#999-1001">source</a></span><a href="#method.take" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.take" class="fnname">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Take.html" title="struct std::io::Take">Take</a>&lt;Self&gt;</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/nightly/std/io/trait.Read.html#method.take">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Write-for-%26%27a%20Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1908-1921">source</a><a href="#impl-Write-for-%26%27a%20Socket" class="anchor"></a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.write-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1909-1911">source</a><a href="#method.write-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#tymethod.write" class="fnname">write</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#tymethod.write">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_vectored-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1914-1916">source</a><a href="#method.write_vectored-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_vectored" class="fnname">write_vectored</a>(&amp;mut self, bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Like <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#tymethod.write"><code>write</code></a>, except that it writes from a slice of buffers. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.flush-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1918-1920">source</a><a href="#method.flush-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#tymethod.flush" class="fnname">flush</a>(&amp;mut self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#tymethod.flush">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_write_vectored-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1478">source</a><a href="#method.is_write_vectored-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_vectored"><code>write_vectored</code></a>
implementation. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.is_write_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_all-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1540">source</a></span><a href="#method.write_all-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_all" class="fnname">write_all</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_all">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_all_vectored-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1605">source</a><a href="#method.write_all_vectored-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_all_vectored" class="fnname">write_all_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_all_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_fmt-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1661">source</a></span><a href="#method.write_fmt-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_fmt" class="fnname">write_fmt</a>(&amp;mut self, fmt: <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Arguments.html" title="struct core::fmt::Arguments">Arguments</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_fmt">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.by_ref-3" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1717-1719">source</a></span><a href="#method.by_ref-3" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.by_ref" class="fnname">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</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/nightly/std/io/trait.Write.html#method.by_ref">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Write-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1893-1906">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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.write" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1894-1896">source</a><a href="#method.write" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#tymethod.write" class="fnname">write</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#tymethod.write">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_vectored" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1899-1901">source</a><a href="#method.write_vectored" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_vectored" class="fnname">write_vectored</a>(&amp;mut self, bufs: &amp;[<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class='docblock'>Like <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#tymethod.write"><code>write</code></a>, except that it writes from a slice of buffers. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.flush" class="method trait-impl has-srclink"><a class="srclink rightside" href="../src/socket2/socket.rs.html#1903-1905">source</a><a href="#method.flush" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#tymethod.flush" class="fnname">flush</a>(&amp;mut self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#tymethod.flush">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.is_write_vectored" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1478">source</a><a href="#method.is_write_vectored" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.is_write_vectored" class="fnname">is_write_vectored</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_vectored"><code>write_vectored</code></a>
implementation. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.is_write_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_all" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1540">source</a></span><a href="#method.write_all" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_all" class="fnname">write_all</a>(&amp;mut self, buf: &amp;[<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_all">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_all_vectored" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1605">source</a><a href="#method.write_all_vectored" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_all_vectored" class="fnname">write_all_vectored</a>(&amp;mut self, bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a>&lt;'_&gt;]) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_all_vectored">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_fmt" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1661">source</a></span><a href="#method.write_fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.write_fmt" class="fnname">write_fmt</a>(&amp;mut self, fmt: <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Arguments.html" title="struct core::fmt::Arguments">Arguments</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/std/io/trait.Write.html#method.write_fmt">Read more</a></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.by_ref-2" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1717-1719">source</a></span><a href="#method.by_ref-2" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html#method.by_ref" class="fnname">by_ref</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self</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/nightly/std/io/trait.Write.html#method.by_ref">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="small-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 has-srclink"><a href="#impl-RefUnwindSafe-for-Socket" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-Send-for-Socket" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-Sync-for-Socket" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-Unpin-for-Socket" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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 has-srclink"><a href="#impl-UnwindSafe-for-Socket" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/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="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-Socket" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/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/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-Socket" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-Socket" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-Socket" class="anchor"></a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.from-12" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from-12" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#717">source</a><a href="#impl-Into%3CU%3E-for-Socket" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#725">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">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/nightly/core/convert/trait.From.html" title="From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#775">source</a><a href="#impl-TryFrom%3CU%3E-for-Socket" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#781">source</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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/nightly/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/nightly/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="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-Socket" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#760">source</a><a href="#impl-TryInto%3CU%3E-for-Socket" class="anchor"></a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/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/nightly/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="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#766">source</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/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/nightly/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/nightly/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></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="socket2" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>