2018-10-28 21:14:05 -05:00

430 lines
27 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `socket` mod in crate `nix`."><meta name="keywords" content="rust, rustlang, rust-lang, socket"><title>nix::sys::socket - 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="../../../dark.css"><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script src="../../../storage.js"></script></head><body class="rustdoc mod"><!--[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">&#9776;</div><p class='location'>Module socket</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></div><p class='location'><a href='../../index.html'>nix</a>::<wbr><a href='../index.html'>sys</a></p><script>window.sidebarCurrent = {name: 'socket', ty: 'mod', relpath: '../'};</script><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press S to search, ? for more options…" type="search"><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'>Module <a href='../../index.html'>nix</a>::<wbr><a href='../index.html'>sys</a>::<wbr><a class="mod" href=''>socket</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'>&#x2212;</span>]</a></span><a class='srclink' href='../../../src/nix/sys/socket/mod.rs.html#1-1000' title='goto source code'>[src]</a></span></h1><div class='docblock'><p>Socket interface functions</p>
<p><a href="http://man7.org/linux/man-pages/man7/socket.7.html">Further reading</a></p>
</div><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
<table>
<tr class=' module-item'>
<td><a class="mod" href="sockopt/index.html"
title='mod nix::sys::socket::sockopt'>sockopt</a></td>
<td class='docblock-short'>
</td>
</tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class="struct" href="struct.CmsgIterator.html"
title='struct nix::sys::socket::CmsgIterator'>CmsgIterator</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.CmsgSpace.html"
title='struct nix::sys::socket::CmsgSpace'>CmsgSpace</a></td>
<td class='docblock-short'>
<p>A structure used to make room in a cmsghdr passed to recvmsg. The
size and alignment match that of a cmsghdr followed by a T, but the
fields are not accessible, as the actual types will change on a call
to recvmsg.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.IpMembershipRequest.html"
title='struct nix::sys::socket::IpMembershipRequest'>IpMembershipRequest</a></td>
<td class='docblock-short'>
<p>Request for multicast socket operations</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Ipv4Addr.html"
title='struct nix::sys::socket::Ipv4Addr'>Ipv4Addr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Ipv6Addr.html"
title='struct nix::sys::socket::Ipv6Addr'>Ipv6Addr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.Ipv6MembershipRequest.html"
title='struct nix::sys::socket::Ipv6MembershipRequest'>Ipv6MembershipRequest</a></td>
<td class='docblock-short'>
<p>Request for ipv6 multicast socket operations</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.LinkAddr.html"
title='struct nix::sys::socket::LinkAddr'>LinkAddr</a></td>
<td class='docblock-short'>
<p>Hardware Address</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.MsgFlags.html"
title='struct nix::sys::socket::MsgFlags'>MsgFlags</a></td>
<td class='docblock-short'>
<p>Flags for send/recv and their relatives</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.NetlinkAddr.html"
title='struct nix::sys::socket::NetlinkAddr'>NetlinkAddr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.RecvMsg.html"
title='struct nix::sys::socket::RecvMsg'>RecvMsg</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.SockFlag.html"
title='struct nix::sys::socket::SockFlag'>SockFlag</a></td>
<td class='docblock-short'>
<p>Additional socket options</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.UnixAddr.html"
title='struct nix::sys::socket::UnixAddr'>UnixAddr</a></td>
<td class='docblock-short'>
<p>A wrapper around <code>sockaddr_un</code>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.UnixCredentials.html"
title='struct nix::sys::socket::UnixCredentials'>UnixCredentials</a></td>
<td class='docblock-short'>
<p>Unix credentials of the sending process.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.cmsghdr.html"
title='struct nix::sys::socket::cmsghdr'>cmsghdr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.msghdr.html"
title='struct nix::sys::socket::msghdr'>msghdr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.sockaddr.html"
title='struct nix::sys::socket::sockaddr'>sockaddr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.sockaddr_in.html"
title='struct nix::sys::socket::sockaddr_in'>sockaddr_in</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.sockaddr_in6.html"
title='struct nix::sys::socket::sockaddr_in6'>sockaddr_in6</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.sockaddr_storage.html"
title='struct nix::sys::socket::sockaddr_storage'>sockaddr_storage</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.sockaddr_un.html"
title='struct nix::sys::socket::sockaddr_un'>sockaddr_un</a></td>
<td class='docblock-short'>
</td>
</tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
<table>
<tr class=' module-item'>
<td><a class="enum" href="enum.AddressFamily.html"
title='enum nix::sys::socket::AddressFamily'>AddressFamily</a></td>
<td class='docblock-short'>
<p>These constants specify the protocol family to be used
in <a href="fn.socket.html"><code>socket</code></a> and <a href="fn.socketpair.html"><code>socketpair</code></a></p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.ControlMessage.html"
title='enum nix::sys::socket::ControlMessage'>ControlMessage</a></td>
<td class='docblock-short'>
<p>A type-safe wrapper around a single control message. More types may
be added to this enum; do not exhaustively pattern-match it.
<a href="http://man7.org/linux/man-pages/man3/cmsg.3.html">Further reading</a></p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.InetAddr.html"
title='enum nix::sys::socket::InetAddr'>InetAddr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.IpAddr.html"
title='enum nix::sys::socket::IpAddr'>IpAddr</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.Shutdown.html"
title='enum nix::sys::socket::Shutdown'>Shutdown</a></td>
<td class='docblock-short'>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.SockAddr.html"
title='enum nix::sys::socket::SockAddr'>SockAddr</a></td>
<td class='docblock-short'>
<p>Represents a socket address</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.SockLevel.html"
title='enum nix::sys::socket::SockLevel'>SockLevel</a></td>
<td class='docblock-short'>
<p>The protocol level at which to get / set socket options. Used as an
argument to <code>getsockopt</code> and <code>setsockopt</code>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.SockProtocol.html"
title='enum nix::sys::socket::SockProtocol'>SockProtocol</a></td>
<td class='docblock-short'>
<p>Constants used in <a href="fn.socket.html"><code>socket</code></a> and <a href="fn.socketpair.html"><code>socketpair</code></a>
to specify the protocol to use.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="enum" href="enum.SockType.html"
title='enum nix::sys::socket::SockType'>SockType</a></td>
<td class='docblock-short'>
<p>These constants are used to specify the communication semantics
when creating a socket with <a href="fn.socket.html"><code>socket()</code></a></p>
</td>
</tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table>
<tr class=' module-item'>
<td><a class="trait" href="trait.GetSockOpt.html"
title='trait nix::sys::socket::GetSockOpt'>GetSockOpt</a></td>
<td class='docblock-short'>
<p>Represents a socket option that can be accessed or set. Used as an argument
to <code>getsockopt</code></p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="trait" href="trait.SetSockOpt.html"
title='trait nix::sys::socket::SetSockOpt'>SetSockOpt</a></td>
<td class='docblock-short'>
<p>Represents a socket option that can be accessed or set. Used as an argument
to <code>setsockopt</code></p>
</td>
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class="fn" href="fn.accept.html"
title='fn nix::sys::socket::accept'>accept</a></td>
<td class='docblock-short'>
<p>Accept a connection on a socket</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.accept4.html"
title='fn nix::sys::socket::accept4'>accept4</a></td>
<td class='docblock-short'>
<p>Accept a connection on a socket</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.bind.html"
title='fn nix::sys::socket::bind'>bind</a></td>
<td class='docblock-short'>
<p>Bind a name to a socket</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.connect.html"
title='fn nix::sys::socket::connect'>connect</a></td>
<td class='docblock-short'>
<p>Initiate a connection on a socket</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.getpeername.html"
title='fn nix::sys::socket::getpeername'>getpeername</a></td>
<td class='docblock-short'>
<p>Get the address of the peer connected to the socket <code>fd</code>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.getsockname.html"
title='fn nix::sys::socket::getsockname'>getsockname</a></td>
<td class='docblock-short'>
<p>Get the current address to which the socket <code>fd</code> is bound.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.getsockopt.html"
title='fn nix::sys::socket::getsockopt'>getsockopt</a></td>
<td class='docblock-short'>
<p>Get the current value for the requested socket option</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.listen.html"
title='fn nix::sys::socket::listen'>listen</a></td>
<td class='docblock-short'>
<p>Listen for connections on a socket</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.recv.html"
title='fn nix::sys::socket::recv'>recv</a></td>
<td class='docblock-short'>
<p>Receive data from a connection-oriented socket. Returns the number of
bytes read</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.recvfrom.html"
title='fn nix::sys::socket::recvfrom'>recvfrom</a></td>
<td class='docblock-short'>
<p>Receive data from a connectionless or connection-oriented socket. Returns
the number of bytes read and the socket address of the sender.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.recvmsg.html"
title='fn nix::sys::socket::recvmsg'>recvmsg</a></td>
<td class='docblock-short'>
<p>Receive message in scatter-gather vectors from a socket, and
optionally receive ancillary data into the provided buffer.
If no ancillary data is desired, use () as the type parameter.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.send.html"
title='fn nix::sys::socket::send'>send</a></td>
<td class='docblock-short'>
<p>Send data to a connection-oriented socket. Returns the number of bytes read</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.sendmsg.html"
title='fn nix::sys::socket::sendmsg'>sendmsg</a></td>
<td class='docblock-short'>
<p>Send data in scatter-gather vectors to a socket, possibly accompanied
by ancillary data. Optionally direct the message at the given address,
as with sendto.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.sendto.html"
title='fn nix::sys::socket::sendto'>sendto</a></td>
<td class='docblock-short'>
<p>Send a message to a socket</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.setsockopt.html"
title='fn nix::sys::socket::setsockopt'>setsockopt</a></td>
<td class='docblock-short'>
<p>Sets the value for the requested socket option</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.shutdown.html"
title='fn nix::sys::socket::shutdown'>shutdown</a></td>
<td class='docblock-short'>
<p>Shut down part of a full-duplex connection.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.sockaddr_storage_to_addr.html"
title='fn nix::sys::socket::sockaddr_storage_to_addr'>sockaddr_storage_to_addr</a><a title='unsafe function' href='#'><sup></sup></a></td>
<td class='docblock-short'>
<p>Return the appropriate <code>SockAddr</code> type from a <code>sockaddr_storage</code> of a certain
size. In C this would usually be done by casting. The <code>len</code> argument
should be the number of bytes in the <code>sockaddr_storage</code> that are actually
allocated and valid. It must be at least as large as all the useful parts
of the structure. Note that in the case of a <code>sockaddr_un</code>, <code>len</code> need not
include the terminating null.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.socket.html"
title='fn nix::sys::socket::socket'>socket</a></td>
<td class='docblock-short'>
<p>Create an endpoint for communication</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.socketpair.html"
title='fn nix::sys::socket::socketpair'>socketpair</a></td>
<td class='docblock-short'>
<p>Create a pair of connected sockets</p>
</td>
</tr></table><h2 id='types' class='section-header'><a href="#types">Type Definitions</a></h2>
<table>
<tr class=' module-item'>
<td><a class="type" href="type.sa_family_t.html"
title='type nix::sys::socket::sa_family_t'>sa_family_t</a></td>
<td class='docblock-short'>
</td>
</tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../../";window.currentCrate = "nix";</script><script src="../../../aliases.js"></script><script src="../../../main.js"></script><script defer src="../../../search-index.js"></script></body></html>