mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-25 12:44:07 +01:00
366 lines
110 KiB
HTML
366 lines
110 KiB
HTML
<!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="API documentation for the Rust `SockRef` struct in crate `socket2`."><meta name="keywords" content="rust, rustlang, rust-lang, SockRef"><title>socket2::SockRef - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../socket2/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct SockRef</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#deref-methods-Socket">Methods from Deref<Target=Socket></a><div class="sidebar-links"><a href="#method.accept">accept</a><a href="#method.accept_raw">accept_raw</a><a href="#method.bind">bind</a><a href="#method.broadcast">broadcast</a><a href="#method.connect">connect</a><a href="#method.connect_timeout">connect_timeout</a><a href="#method.join_multicast_v4">join_multicast_v4</a><a href="#method.join_multicast_v6">join_multicast_v6</a><a href="#method.keepalive">keepalive</a><a href="#method.leave_multicast_v4">leave_multicast_v4</a><a href="#method.leave_multicast_v6">leave_multicast_v6</a><a href="#method.linger">linger</a><a href="#method.listen">listen</a><a href="#method.local_addr">local_addr</a><a href="#method.multicast_hops_v6">multicast_hops_v6</a><a href="#method.multicast_if_v4">multicast_if_v4</a><a href="#method.multicast_if_v6">multicast_if_v6</a><a href="#method.multicast_loop_v4">multicast_loop_v4</a><a href="#method.multicast_loop_v6">multicast_loop_v6</a><a href="#method.multicast_ttl_v4">multicast_ttl_v4</a><a href="#method.nodelay">nodelay</a><a href="#method.only_v6">only_v6</a><a href="#method.out_of_band_inline">out_of_band_inline</a><a href="#method.peek">peek</a><a href="#method.peek_from">peek_from</a><a href="#method.peer_addr">peer_addr</a><a href="#method.read_timeout">read_timeout</a><a href="#method.recv">recv</a><a href="#method.recv_buffer_size">recv_buffer_size</a><a href="#method.recv_from">recv_from</a><a href="#method.recv_from_vectored">recv_from_vectored</a><a href="#method.recv_from_vectored_with_flags">recv_from_vectored_with_flags</a><a href="#method.recv_from_with_flags">recv_from_with_flags</a><a href="#method.recv_out_of_band">recv_out_of_band</a><a href="#method.recv_vectored">recv_vectored</a><a href="#method.recv_vectored_with_flags">recv_vectored_with_flags</a><a href="#method.recv_with_flags">recv_with_flags</a><a href="#method.reuse_address">reuse_address</a><a href="#method.send">send</a><a href="#method.send_buffer_size">send_buffer_size</a><a href="#method.send_out_of_band">send_out_of_band</a><a href="#method.send_to">send_to</a><a href="#method.send_to_vectored">send_to_vectored</a><a href="#method.send_to_vectored_with_flags">send_to_vectored_with_flags</a><a href="#method.send_to_with_flags">send_to_with_flags</a><a href="#method.send_vectored">send_vectored</a><a href="#method.send_vectored_with_flags">send_vectored_with_flags</a><a href="#method.send_with_flags">send_with_flags</a><a href="#method.set_broadcast">set_broadcast</a><a href="#method.set_keepalive">set_keepalive</a><a href="#method.set_linger">set_linger</a><a href="#method.set_multicast_hops_v6">set_multicast_hops_v6</a><a href="#method.set_multicast_if_v4">set_multicast_if_v4</a><a href="#method.set_multicast_if_v6">set_multicast_if_v6</a><a href="#method.set_multicast_loop_v4">set_multicast_loop_v4</a><a href="#method.set_multicast_loop_v6">set_multicast_loop_v6</a><a href="#method.set_multicast_ttl_v4">set_multicast_ttl_v4</a><a href="#method.set_nodelay">set_nodelay</a><a href="#method.set_nonblocking">set_nonblocking</a><a href="#method.set_only_v6">set_only_v6</a><a href="#method.set_out_of_band_inline">set_out_of_band_inline</a><a href="#method.set_read_timeout">set_read_timeout</a><a href="#method.set_recv_buffer_size">set_recv_buffer_size</a><a href="#method.set_reuse_address">set_reuse_address</a><a href="#method.set_send_buffer_size">set_send_buffer_size</a><a href="#method.set_tcp_keepalive">set_tcp_keepalive</a><a href="#method.set_ttl">set_ttl</a><a href="#method.set_unicast_hops_v6">set_unicast_hops_v6</a><a href="#method.set_write_timeout">set_write_timeout</a><a href="#method.shutdown">shutdown</a><a href="#method.take_error">take_error</a><a href="#method.try_clone">try_clone</a><a href="#method.ttl">ttl</a><a href="#method.unicast_hops_v6">unicast_hops_v6</a><a href="#method.write_timeout">write_timeout</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a><a href="#impl-Deref">Deref</a><a href="#impl-From%3C%26%27s%20S%3E">From<&'s S></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="index.html">socket2</a></p><div id="sidebar-vars" data-name="SockRef" data-ty="struct" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">socket2</a>::<wbr><a class="struct" href="">SockRef</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/socket2/sockref.rs.html#59-67" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct SockRef<'s> { /* fields omitted */ }</pre></div><div class="docblock"><p>A reference to a <a href="../socket2/struct.Socket.html" title="Socket"><code>Socket</code></a> that can be used to configure socket types other
|
||
than the <code>Socket</code> type itself.</p>
|
||
<p>This allows for example a <a href="https://doc.rust-lang.org/nightly/std/net/tcp/struct.TcpStream.html"><code>TcpStream</code></a>, found in the standard library, to
|
||
be configured using all the additional methods found in the <a href="../socket2/struct.Socket.html" title="Socket"><code>Socket</code></a> API.</p>
|
||
<p><code>SockRef</code> can be created from any socket type that implements <a href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html"><code>AsRawFd</code></a>
|
||
(Unix) or <a href="std::os::windows::io::AsRawSocket"><code>AsRawSocket</code></a> (Windows) using the <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="From"><code>From</code></a> implementation, but
|
||
the caller must ensure the file descriptor/socket is a valid.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">net</span>::{<span class="ident">TcpStream</span>, <span class="ident">SocketAddr</span>};
|
||
|
||
<span class="kw">use</span> <span class="ident">socket2</span>::<span class="ident">SockRef</span>;
|
||
|
||
<span class="comment">// Create `TcpStream` from the standard library.</span>
|
||
<span class="kw">let</span> <span class="ident">address</span>: <span class="ident">SocketAddr</span> <span class="op">=</span> <span class="string">"127.0.0.1:1234"</span>.<span class="ident">parse</span>()<span class="question-mark">?</span>;
|
||
<span class="kw">let</span> <span class="ident">stream</span> <span class="op">=</span> <span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="ident">address</span>)<span class="question-mark">?</span>;
|
||
|
||
<span class="comment">// Create a `SockRef`erence to the stream.</span>
|
||
<span class="kw">let</span> <span class="ident">socket_ref</span> <span class="op">=</span> <span class="ident">SockRef</span>::<span class="ident">from</span>(<span class="kw-2">&</span><span class="ident">stream</span>);
|
||
<span class="comment">// Use `Socket::set_nodelay` on the stream.</span>
|
||
<span class="ident">socket_ref</span>.<span class="ident">set_nodelay</span>(<span class="bool-val">true</span>)<span class="question-mark">?</span>;
|
||
<span class="ident">drop</span>(<span class="ident">socket_ref</span>);
|
||
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">stream</span>.<span class="ident">nodelay</span>()<span class="question-mark">?</span>, <span class="bool-val">true</span>);</pre></div>
|
||
</div><h2 id="deref-methods-Socket" class="small-section-header">Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = <a class="struct" href="../socket2/struct.Socket.html" title="struct socket2::Socket">Socket</a>><a href="#deref-methods-Socket" class="anchor"></a></h2><div class="impl-items"><h4 id="method.bind" class="method"><code>pub fn <a href="#method.bind" class="fnname">bind</a>(&self, address: &<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#145-147" title="goto source code">[src]</a></h4><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><h4 id="method.connect" class="method"><code>pub fn <a href="#method.connect" class="fnname">connect</a>(&self, address: &<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#163-165" title="goto source code">[src]</a></h4><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>
|
||
<h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1>
|
||
<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><h4 id="method.connect_timeout" class="method"><code>pub fn <a href="#method.connect_timeout" class="fnname">connect_timeout</a>(&self, addr: &<a class="struct" href="../socket2/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>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#186-200" title="goto source code">[src]</a></h4><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>
|
||
<h1 id="warnings" class="section-header"><a href="#warnings">Warnings</a></h1>
|
||
<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><h4 id="method.listen" class="method"><code>pub fn <a href="#method.listen" class="fnname">listen</a>(&self, backlog: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#210-212" title="goto source code">[src]</a></h4><div class="docblock"><p>Mark a socket as ready to accept incoming connection requests using
|
||
<a href="../socket2/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><h4 id="method.accept" class="method"><code>pub fn <a href="#method.accept" class="fnname">accept</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../socket2/struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#221-250" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.new" title="Socket::new"><code>Socket::new</code></a>,
|
||
<a href="../socket2/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><h4 id="method.accept_raw" class="method"><code>pub fn <a href="#method.accept_raw" class="fnname">accept_raw</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../socket2/struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#256-258" title="goto source code">[src]</a></h4><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><h4 id="method.local_addr" class="method"><code>pub fn <a href="#method.local_addr" class="fnname">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#268-270" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the socket address of the local half of this socket.</p>
|
||
<h1 id="notes-1" class="section-header"><a href="#notes-1">Notes</a></h1>
|
||
<p>Depending on the OS this may return an error if the socket is not
|
||
<a href="../socket2/struct.Socket.html#method.bind">bound</a>.</p>
|
||
</div><h4 id="method.peer_addr" class="method"><code>pub fn <a href="#method.peer_addr" class="fnname">peer_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#279-281" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the socket address of the remote peer of this socket.</p>
|
||
<h1 id="notes-2" class="section-header"><a href="#notes-2">Notes</a></h1>
|
||
<p>This returns an error if the socket is not <a href="../socket2/struct.Socket.html#method.connect"><code>connect</code>ed</a>.</p>
|
||
</div><h4 id="method.try_clone" class="method"><code>pub fn <a href="#method.try_clone" class="fnname">try_clone</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="../socket2/struct.Socket.html" title="struct socket2::Socket">Socket</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#296-298" title="goto source code">[src]</a></h4><div class="docblock"><p>Creates a new independently owned handle to the underlying socket.</p>
|
||
<h1 id="notes-3" class="section-header"><a href="#notes-3">Notes</a></h1>
|
||
<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><h4 id="method.set_nonblocking" class="method"><code>pub fn <a href="#method.set_nonblocking" class="fnname">set_nonblocking</a>(&self, nonblocking: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#308-310" title="goto source code">[src]</a></h4><div class="docblock"><p>Moves this TCP stream into or out of nonblocking mode.</p>
|
||
<h1 id="notes-4" class="section-header"><a href="#notes-4">Notes</a></h1>
|
||
<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><h4 id="method.shutdown" class="method"><code>pub fn <a href="#method.shutdown" class="fnname">shutdown</a>(&self, how: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/enum.Shutdown.html" title="enum std::net::Shutdown">Shutdown</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#316-318" title="goto source code">[src]</a></h4><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><h4 id="method.recv" class="method"><code>pub fn <a href="#method.recv" class="fnname">recv</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#340-342" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||
connected.</p>
|
||
<p>The <a href="../socket2/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>
|
||
<h1 id="safety" class="section-header"><a href="#safety">Safety</a></h1>
|
||
<p>Normally casting a <code>&mut [u8]</code> to <code>&mut [MaybeUninit<u8>]</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>&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>&mut [u8]</code>, allowing initialised buffers to be used
|
||
without using <code>unsafe</code>.</p>
|
||
</div><h4 id="method.recv_out_of_band" class="method"><code>pub fn <a href="#method.recv_out_of_band" class="fnname">recv_out_of_band</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#351-353" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.recv"><code>recv</code></a>, <a href="../socket2/struct.Socket.html#method.out_of_band_inline"><code>out_of_band_inline</code></a>.</p>
|
||
</div><h4 id="method.recv_with_flags" class="method"><code>pub fn <a href="#method.recv_with_flags" class="fnname">recv_with_flags</a>(<br> &self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#359-365" title="goto source code">[src]</a></h4><div class="docblock"><p>Identical to <a href="../socket2/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><h4 id="method.recv_vectored" class="method"><code>pub fn <a href="#method.recv_vectored" class="fnname">recv_vectored</a>(<br> &self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="struct" href="../socket2/struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../socket2/struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#393-398" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||
connected. Unlike <a href="../socket2/struct.Socket.html#method.recv"><code>recv</code></a> this allows passing multiple buffers.</p>
|
||
<p>The <a href="../socket2/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="../socket2/struct.RecvFlags.html" title="RecvFlags"><code>RecvFlags</code></a> for more information about
|
||
the returned flags.</p>
|
||
<h1 id="safety-1" class="section-header"><a href="#safety-1">Safety</a></h1>
|
||
<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>&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>&mut [IoSliceMut]</code>, allowing initialised
|
||
buffers to be used without using <code>unsafe</code>.</p>
|
||
</div><h4 id="method.recv_vectored_with_flags" class="method"><code>pub fn <a href="#method.recv_vectored_with_flags" class="fnname">recv_vectored_with_flags</a>(<br> &self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="struct" href="../socket2/struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../socket2/struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#412-418" title="goto source code">[src]</a></h4><div class="docblock"><p>Identical to <a href="../socket2/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>
|
||
<h1 id="safety-2" class="section-header"><a href="#safety-2">Safety</a></h1>
|
||
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
|
||
as <a href="../socket2/struct.Socket.html#method.recv_vectored"><code>recv_vectored</code></a>.</p>
|
||
</div><h4 id="method.peek" class="method"><code>pub fn <a href="#method.peek" class="fnname">peek</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#433-435" title="goto source code">[src]</a></h4><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>
|
||
<h1 id="safety-3" class="section-header"><a href="#safety-3">Safety</a></h1>
|
||
<p><code>peek</code> makes the same safety guarantees regarding the <code>buf</code>fer as
|
||
<a href="../socket2/struct.Socket.html#method.recv"><code>recv</code></a>.</p>
|
||
</div><h4 id="method.recv_from" class="method"><code>pub fn <a href="#method.recv_from" class="fnname">recv_from</a>(<br> &self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#446-448" title="goto source code">[src]</a></h4><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>
|
||
<h1 id="safety-4" class="section-header"><a href="#safety-4">Safety</a></h1>
|
||
<p><code>recv_from</code> makes the same safety guarantees regarding the <code>buf</code>fer as
|
||
<a href="../socket2/struct.Socket.html#method.recv"><code>recv</code></a>.</p>
|
||
</div><h4 id="method.recv_from_with_flags" class="method"><code>pub fn <a href="#method.recv_from_with_flags" class="fnname">recv_from_with_flags</a>(<br> &self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#454-460" title="goto source code">[src]</a></h4><div class="docblock"><p>Identical to <a href="../socket2/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><h4 id="method.recv_from_vectored" class="method"><code>pub fn <a href="#method.recv_from_vectored" class="fnname">recv_from_vectored</a>(<br> &self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="struct" href="../socket2/struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../socket2/struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>, <a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#475-480" title="goto source code">[src]</a></h4><div class="docblock"><p>Receives data from the socket. Returns the amount of bytes read, the
|
||
<a href="../socket2/struct.RecvFlags.html" title="RecvFlags"><code>RecvFlags</code></a> and the remote address from the data is coming. Unlike
|
||
<a href="../socket2/struct.Socket.html#method.recv_from"><code>recv_from</code></a> this allows passing multiple buffers.</p>
|
||
<h1 id="safety-5" class="section-header"><a href="#safety-5">Safety</a></h1>
|
||
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
|
||
as <a href="../socket2/struct.Socket.html#method.recv_vectored"><code>recv_vectored</code></a>.</p>
|
||
</div><h4 id="method.recv_from_vectored_with_flags" class="method"><code>pub fn <a href="#method.recv_from_vectored_with_flags" class="fnname">recv_from_vectored_with_flags</a>(<br> &self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="struct" href="../socket2/struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../socket2/struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>, <a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#494-500" title="goto source code">[src]</a></h4><div class="docblock"><p>Identical to <a href="../socket2/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>
|
||
<h1 id="safety-6" class="section-header"><a href="#safety-6">Safety</a></h1>
|
||
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
|
||
as <a href="../socket2/struct.Socket.html#method.recv_vectored"><code>recv_vectored</code></a>.</p>
|
||
</div><h4 id="method.peek_from" class="method"><code>pub fn <a href="#method.peek_from" class="fnname">peek_from</a>(<br> &self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><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><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#516-518" title="goto source code">[src]</a></h4><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>
|
||
<h1 id="safety-7" class="section-header"><a href="#safety-7">Safety</a></h1>
|
||
<p><code>peek_from</code> makes the same safety guarantees regarding the <code>buf</code>fer as
|
||
<a href="../socket2/struct.Socket.html#method.recv"><code>recv</code></a>.</p>
|
||
</div><h4 id="method.send" class="method"><code>pub fn <a href="#method.send" class="fnname">send</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#526-528" title="goto source code">[src]</a></h4><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><h4 id="method.send_with_flags" class="method"><code>pub fn <a href="#method.send_with_flags" class="fnname">send_with_flags</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#534-536" title="goto source code">[src]</a></h4><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><h4 id="method.send_vectored" class="method"><code>pub fn <a href="#method.send_vectored" class="fnname">send_vectored</a>(&self, bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#540-542" title="goto source code">[src]</a></h4><div class="docblock"><p>Send data to the connected peer. Returns the amount of bytes written.</p>
|
||
</div><h4 id="method.send_vectored_with_flags" class="method"><code>pub fn <a href="#method.send_vectored_with_flags" class="fnname">send_vectored_with_flags</a>(<br> &self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#549-555" title="goto source code">[src]</a></h4><div class="docblock"><p>Identical to <a href="../socket2/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><h4 id="method.send_out_of_band" class="method"><code>pub fn <a href="#method.send_out_of_band" class="fnname">send_out_of_band</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#564-566" title="goto source code">[src]</a></h4><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><h4 id="method.send_to" class="method"><code>pub fn <a href="#method.send_to" class="fnname">send_to</a>(&self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, addr: &<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#572-574" title="goto source code">[src]</a></h4><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><h4 id="method.send_to_with_flags" class="method"><code>pub fn <a href="#method.send_to_with_flags" class="fnname">send_to_with_flags</a>(<br> &self, <br> buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> addr: &<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>, <br> flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#580-587" title="goto source code">[src]</a></h4><div class="docblock"><p>Identical to <a href="../socket2/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><h4 id="method.send_to_vectored" class="method"><code>pub fn <a href="#method.send_to_vectored" class="fnname">send_to_vectored</a>(<br> &self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> addr: &<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#592-594" title="goto source code">[src]</a></h4><div class="docblock"><p>Send data to a peer listening on <code>addr</code>. Returns the amount of bytes
|
||
written.</p>
|
||
</div><h4 id="method.send_to_vectored_with_flags" class="method"><code>pub fn <a href="#method.send_to_vectored_with_flags" class="fnname">send_to_vectored_with_flags</a>(<br> &self, <br> bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&[</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <br> addr: &<a class="struct" href="../socket2/struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>, <br> flags: <a class="type" href="../libc/unix/type.c_int.html" title="type libc::unix::c_int">c_int</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#601-608" title="goto source code">[src]</a></h4><div class="docblock"><p>Identical to <a href="../socket2/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></div><div class="impl-items"><h4 id="method.broadcast" class="method"><code>pub fn <a href="#method.broadcast" class="fnname">broadcast</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#672-677" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_broadcast"><code>set_broadcast</code></a>.</p>
|
||
</div><h4 id="method.set_broadcast" class="method"><code>pub fn <a href="#method.set_broadcast" class="fnname">set_broadcast</a>(&self, broadcast: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#683-692" title="goto source code">[src]</a></h4><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><h4 id="method.take_error" class="method"><code>pub fn <a href="#method.take_error" class="fnname">take_error</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</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>>></code><a class="srclink" href="../src/socket2/socket.rs.html#699-705" title="goto source code">[src]</a></h4><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><h4 id="method.keepalive" class="method"><code>pub fn <a href="#method.keepalive" class="fnname">keepalive</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#712-717" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_keepalive"><code>set_keepalive</code></a>.</p>
|
||
</div><h4 id="method.set_keepalive" class="method"><code>pub fn <a href="#method.set_keepalive" class="fnname">set_keepalive</a>(&self, keepalive: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#722-731" title="goto source code">[src]</a></h4><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><h4 id="method.linger" class="method"><code>pub fn <a href="#method.linger" class="fnname">linger</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></code><a class="srclink" href="../src/socket2/socket.rs.html#738-742" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_linger"><code>set_linger</code></a>.</p>
|
||
</div><h4 id="method.set_linger" class="method"><code>pub fn <a href="#method.set_linger" class="fnname">set_linger</a>(&self, linger: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#758-761" title="goto source code">[src]</a></h4><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>
|
||
<h1 id="notes-5" class="section-header"><a href="#notes-5">Notes</a></h1>
|
||
<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><h4 id="method.out_of_band_inline" class="method"><code>pub fn <a href="#method.out_of_band_inline" class="fnname">out_of_band_inline</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#769-774" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_out_of_band_inline"><code>set_out_of_band_inline</code></a>.</p>
|
||
</div><h4 id="method.set_out_of_band_inline" class="method"><code>pub fn <a href="#method.set_out_of_band_inline" class="fnname">set_out_of_band_inline</a>(&self, oob_inline: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#783-792" title="goto source code">[src]</a></h4><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><h4 id="method.recv_buffer_size" class="method"><code>pub fn <a href="#method.recv_buffer_size" class="fnname">recv_buffer_size</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#799-804" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_recv_buffer_size"><code>set_recv_buffer_size</code></a>.</p>
|
||
</div><h4 id="method.set_recv_buffer_size" class="method"><code>pub fn <a href="#method.set_recv_buffer_size" class="fnname">set_recv_buffer_size</a>(&self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#810-812" title="goto source code">[src]</a></h4><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><h4 id="method.read_timeout" class="method"><code>pub fn <a href="#method.read_timeout" class="fnname">read_timeout</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></code><a class="srclink" href="../src/socket2/socket.rs.html#818-820" title="goto source code">[src]</a></h4><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><h4 id="method.set_read_timeout" class="method"><code>pub fn <a href="#method.set_read_timeout" class="fnname">set_read_timeout</a>(&self, duration: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#826-828" title="goto source code">[src]</a></h4><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><h4 id="method.reuse_address" class="method"><code>pub fn <a href="#method.reuse_address" class="fnname">reuse_address</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#835-840" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_reuse_address"><code>set_reuse_address</code></a>.</p>
|
||
</div><h4 id="method.set_reuse_address" class="method"><code>pub fn <a href="#method.set_reuse_address" class="fnname">set_reuse_address</a>(&self, reuse: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#847-856" title="goto source code">[src]</a></h4><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><h4 id="method.send_buffer_size" class="method"><code>pub fn <a href="#method.send_buffer_size" class="fnname">send_buffer_size</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#863-868" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_send_buffer_size"><code>set_send_buffer_size</code></a>.</p>
|
||
</div><h4 id="method.set_send_buffer_size" class="method"><code>pub fn <a href="#method.set_send_buffer_size" class="fnname">set_send_buffer_size</a>(&self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#874-876" title="goto source code">[src]</a></h4><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><h4 id="method.write_timeout" class="method"><code>pub fn <a href="#method.write_timeout" class="fnname">write_timeout</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></code><a class="srclink" href="../src/socket2/socket.rs.html#882-884" title="goto source code">[src]</a></h4><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><h4 id="method.set_write_timeout" class="method"><code>pub fn <a href="#method.set_write_timeout" class="fnname">set_write_timeout</a>(&self, duration: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#890-892" title="goto source code">[src]</a></h4><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></div><div class="impl-items"><h4 id="method.join_multicast_v4" class="method"><code>pub fn <a href="#method.join_multicast_v4" class="fnname">join_multicast_v4</a>(<br> &self, <br> multiaddr: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a>, <br> interface: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#929-935" title="goto source code">[src]</a></h4><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/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><h4 id="method.leave_multicast_v4" class="method"><code>pub fn <a href="#method.leave_multicast_v4" class="fnname">leave_multicast_v4</a>(<br> &self, <br> multiaddr: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a>, <br> interface: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#942-948" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.join_multicast_v4"><code>join_multicast_v4</code></a>.</p>
|
||
</div><h4 id="method.multicast_if_v4" class="method"><code>pub fn <a href="#method.multicast_if_v4" class="fnname">multicast_if_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#955-959" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_multicast_if_v4"><code>set_multicast_if_v4</code></a>.</p>
|
||
</div><h4 id="method.set_multicast_if_v4" class="method"><code>pub fn <a href="#method.set_multicast_if_v4" class="fnname">set_multicast_if_v4</a>(&self, interface: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv4Addr.html" title="struct std::net::ip::Ipv4Addr">Ipv4Addr</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#964-967" title="goto source code">[src]</a></h4><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><h4 id="method.multicast_loop_v4" class="method"><code>pub fn <a href="#method.multicast_loop_v4" class="fnname">multicast_loop_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#974-979" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_multicast_loop_v4"><code>set_multicast_loop_v4</code></a>.</p>
|
||
</div><h4 id="method.set_multicast_loop_v4" class="method"><code>pub fn <a href="#method.set_multicast_loop_v4" class="fnname">set_multicast_loop_v4</a>(&self, loop_v4: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#985-994" title="goto source code">[src]</a></h4><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><h4 id="method.multicast_ttl_v4" class="method"><code>pub fn <a href="#method.multicast_ttl_v4" class="fnname">multicast_ttl_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1001-1006" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_multicast_ttl_v4"><code>set_multicast_ttl_v4</code></a>.</p>
|
||
</div><h4 id="method.set_multicast_ttl_v4" class="method"><code>pub fn <a href="#method.set_multicast_ttl_v4" class="fnname">set_multicast_ttl_v4</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1015-1024" title="goto source code">[src]</a></h4><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><h4 id="method.ttl" class="method"><code>pub fn <a href="#method.ttl" class="fnname">ttl</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1031-1035" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_ttl"><code>set_ttl</code></a>.</p>
|
||
</div><h4 id="method.set_ttl" class="method"><code>pub fn <a href="#method.set_ttl" class="fnname">set_ttl</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1041-1043" title="goto source code">[src]</a></h4><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></div><div class="impl-items"><h4 id="method.join_multicast_v6" class="method"><code>pub fn <a href="#method.join_multicast_v6" class="fnname">join_multicast_v6</a>(<br> &self, <br> multiaddr: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv6Addr.html" title="struct std::net::ip::Ipv6Addr">Ipv6Addr</a>, <br> interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1059-1073" title="goto source code">[src]</a></h4><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><h4 id="method.leave_multicast_v6" class="method"><code>pub fn <a href="#method.leave_multicast_v6" class="fnname">leave_multicast_v6</a>(<br> &self, <br> multiaddr: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/net/ip/struct.Ipv6Addr.html" title="struct std::net::ip::Ipv6Addr">Ipv6Addr</a>, <br> interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1082-1096" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.join_multicast_v6"><code>join_multicast_v6</code></a>.</p>
|
||
</div><h4 id="method.multicast_hops_v6" class="method"><code>pub fn <a href="#method.multicast_hops_v6" class="fnname">multicast_hops_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1103-1108" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_multicast_hops_v6"><code>set_multicast_hops_v6</code></a>.</p>
|
||
</div><h4 id="method.set_multicast_hops_v6" class="method"><code>pub fn <a href="#method.set_multicast_hops_v6" class="fnname">set_multicast_hops_v6</a>(&self, hops: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1115-1124" title="goto source code">[src]</a></h4><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><h4 id="method.multicast_if_v6" class="method"><code>pub fn <a href="#method.multicast_if_v6" class="fnname">multicast_if_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1131-1136" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_multicast_if_v6"><code>set_multicast_if_v6</code></a>.</p>
|
||
</div><h4 id="method.set_multicast_if_v6" class="method"><code>pub fn <a href="#method.set_multicast_if_v6" class="fnname">set_multicast_if_v6</a>(&self, interface: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1143-1152" title="goto source code">[src]</a></h4><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><h4 id="method.multicast_loop_v6" class="method"><code>pub fn <a href="#method.multicast_loop_v6" class="fnname">multicast_loop_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1159-1164" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_multicast_loop_v6"><code>set_multicast_loop_v6</code></a>.</p>
|
||
</div><h4 id="method.set_multicast_loop_v6" class="method"><code>pub fn <a href="#method.set_multicast_loop_v6" class="fnname">set_multicast_loop_v6</a>(&self, loop_v6: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1170-1179" title="goto source code">[src]</a></h4><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><h4 id="method.unicast_hops_v6" class="method"><code>pub fn <a href="#method.unicast_hops_v6" class="fnname">unicast_hops_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1184-1189" title="goto source code">[src]</a></h4><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><h4 id="method.set_unicast_hops_v6" class="method"><code>pub fn <a href="#method.set_unicast_hops_v6" class="fnname">set_unicast_hops_v6</a>(&self, hops: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1194-1203" title="goto source code">[src]</a></h4><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><h4 id="method.only_v6" class="method"><code>pub fn <a href="#method.only_v6" class="fnname">only_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1210-1215" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_only_v6"><code>set_only_v6</code></a>.</p>
|
||
</div><h4 id="method.set_only_v6" class="method"><code>pub fn <a href="#method.set_only_v6" class="fnname">set_only_v6</a>(&self, only_v6: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1225-1234" title="goto source code">[src]</a></h4><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></div><div class="impl-items"><h4 id="method.set_tcp_keepalive" class="method"><code>pub fn <a href="#method.set_tcp_keepalive" class="fnname">set_tcp_keepalive</a>(&self, params: &<a class="struct" href="../socket2/struct.TcpKeepalive.html" title="struct socket2::TcpKeepalive">TcpKeepalive</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1341-1344" title="goto source code">[src]</a></h4><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="../socket2/struct.TcpKeepalive.html" title="TcpKeepalive"><code>TcpKeepalive</code></a> struct. At a minimum, all systems
|
||
support configuring the <a href="../socket2/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>
|
||
<h1 id="notes-6" class="section-header"><a href="#notes-6">Notes</a></h1>
|
||
<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>
|
||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">time</span>::<span class="ident">Duration</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">socket2</span>::{<span class="ident">Socket</span>, <span class="ident">TcpKeepalive</span>, <span class="ident">Domain</span>, <span class="ident">Type</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">socket</span> <span class="op">=</span> <span class="ident">Socket</span>::<span class="ident">new</span>(<span class="ident">Domain</span>::<span class="ident">IPV4</span>, <span class="ident">Type</span>::<span class="ident">STREAM</span>, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
|
||
<span class="kw">let</span> <span class="ident">keepalive</span> <span class="op">=</span> <span class="ident">TcpKeepalive</span>::<span class="ident">new</span>()
|
||
.<span class="ident">with_time</span>(<span class="ident">Duration</span>::<span class="ident">from_secs</span>(<span class="number">4</span>));
|
||
<span class="comment">// Depending on the target operating system, we may also be able to</span>
|
||
<span class="comment">// configure the keepalive probe interval and/or the number of</span>
|
||
<span class="comment">// retries here as well.</span>
|
||
|
||
<span class="ident">socket</span>.<span class="ident">set_tcp_keepalive</span>(<span class="kw-2">&</span><span class="ident">keepalive</span>)<span class="question-mark">?</span>;</pre></div>
|
||
</div><h4 id="method.nodelay" class="method"><code>pub fn <a href="#method.nodelay" class="fnname">nodelay</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1351-1356" title="goto source code">[src]</a></h4><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="../socket2/struct.Socket.html#method.set_nodelay"><code>set_nodelay</code></a>.</p>
|
||
</div><h4 id="method.set_nodelay" class="method"><code>pub fn <a href="#method.set_nodelay" class="fnname">set_nodelay</a>(&self, nodelay: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code><a class="srclink" href="../src/socket2/socket.rs.html#1365-1374" title="goto source code">[src]</a></h4><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></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-Debug" class="impl"><code class="in-band">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="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'_></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/socket2/sockref.rs.html#105-113" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/socket2/sockref.rs.html#106-112" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||
</div></div><h3 id="impl-Deref" class="impl"><code class="in-band">impl<'s> <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'s></code><a href="#impl-Deref" class="anchor"></a><a class="srclink" href="../src/socket2/sockref.rs.html#69-75" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Target" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target" class="type">Target</a> = <a class="struct" href="../socket2/struct.Socket.html" title="struct socket2::Socket">Socket</a></code></h4><div class='docblock'><p>The resulting type after dereferencing.</p>
|
||
</div><h4 id="method.deref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref" class="fnname">deref</a>(&self) -> &Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a></code><a class="srclink" href="../src/socket2/sockref.rs.html#72-74" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Dereferences the value.</p>
|
||
</div></div><h3 id="impl-From%3C%26%27s%20S%3E" class="impl"><code class="in-band">impl<'s, S> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'s </a>S> for <a class="struct" href="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'s> <span class="where fmt-newline">where<br> S: <a class="trait" href="https://doc.rust-lang.org/nightly/std/sys/unix/ext/io/trait.AsRawFd.html" title="trait std::sys::unix::ext::io::AsRawFd">AsRawFd</a>, </span></code><a href="#impl-From%3C%26%27s%20S%3E" class="anchor"></a><a class="srclink" href="../src/socket2/sockref.rs.html#78-89" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(socket: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'s </a>S) -> Self</code><a class="srclink" href="../src/socket2/sockref.rs.html#83-88" title="goto source code">[src]</a></h4><div class="docblock"><p>The caller must ensure <code>S</code> is actually a socket.</p>
|
||
</div></div></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"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl<'s> <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'s></code><a href="#impl-RefUnwindSafe" class="anchor"></a><a class="srclink" href="../src/socket2/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl<'s> <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="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'s></code><a href="#impl-Send" class="anchor"></a><a class="srclink" href="../src/socket2/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl<'s> <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="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'s></code><a href="#impl-Sync" class="anchor"></a><a class="srclink" href="../src/socket2/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl<'s> <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="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'s></code><a href="#impl-Unpin" class="anchor"></a><a class="srclink" href="../src/socket2/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl<'s> <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../socket2/struct.SockRef.html" title="struct socket2::SockRef">SockRef</a><'s></code><a href="#impl-UnwindSafe" class="anchor"></a><a class="srclink" href="../src/socket2/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl<T> <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> 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></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#207-211" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
|
||
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214-218" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#215" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>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></p>
|
||
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-549" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#546" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#534-541" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#538" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#582-591" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div><h4 id="method.try_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#588" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#568-577" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#574" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="socket2"></div>
|
||
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |