1152 lines
335 KiB
HTML
1152 lines
335 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="Owned wrapper around a system socket."><title>Socket in socket2 - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="socket2" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Socket</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../socket2/index.html">socket2</a><span class="version">0.6.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Socket</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#converting-to-and-from-other-types" title="Converting to and from other types">Converting to and from other types</a></li><li><a href="#notes" title="Notes">Notes</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.accept" title="accept">accept</a></li><li><a href="#method.accept4" title="accept4">accept4</a></li><li><a href="#method.accept_raw" title="accept_raw">accept_raw</a></li><li><a href="#method.attach_filter" title="attach_filter">attach_filter</a></li><li><a href="#method.bind" title="bind">bind</a></li><li><a href="#method.bind_device" title="bind_device">bind_device</a></li><li><a href="#method.bind_device_by_index_v4" title="bind_device_by_index_v4">bind_device_by_index_v4</a></li><li><a href="#method.bind_device_by_index_v6" title="bind_device_by_index_v6">bind_device_by_index_v6</a></li><li><a href="#method.broadcast" title="broadcast">broadcast</a></li><li><a href="#method.busy_poll" title="busy_poll">busy_poll</a></li><li><a href="#method.connect" title="connect">connect</a></li><li><a href="#method.connect_timeout" title="connect_timeout">connect_timeout</a></li><li><a href="#method.cookie" title="cookie">cookie</a></li><li><a href="#method.cpu_affinity" title="cpu_affinity">cpu_affinity</a></li><li><a href="#method.dccp_available_ccids" title="dccp_available_ccids">dccp_available_ccids</a></li><li><a href="#method.dccp_cur_mps" title="dccp_cur_mps">dccp_cur_mps</a></li><li><a href="#method.dccp_qpolicy_txqlen" title="dccp_qpolicy_txqlen">dccp_qpolicy_txqlen</a></li><li><a href="#method.dccp_recv_cscov" title="dccp_recv_cscov">dccp_recv_cscov</a></li><li><a href="#method.dccp_send_cscov" title="dccp_send_cscov">dccp_send_cscov</a></li><li><a href="#method.dccp_server_timewait" title="dccp_server_timewait">dccp_server_timewait</a></li><li><a href="#method.dccp_service" title="dccp_service">dccp_service</a></li><li><a href="#method.dccp_tx_ccid" title="dccp_tx_ccid">dccp_tx_ccid</a></li><li><a href="#method.dccp_xx_ccid" title="dccp_xx_ccid">dccp_xx_ccid</a></li><li><a href="#method.detach_filter" title="detach_filter">detach_filter</a></li><li><a href="#method.device" title="device">device</a></li><li><a href="#method.device_index_v4" title="device_index_v4">device_index_v4</a></li><li><a href="#method.device_index_v6" title="device_index_v6">device_index_v6</a></li><li><a href="#method.domain" title="domain">domain</a></li><li><a href="#method.freebind_v4" title="freebind_v4">freebind_v4</a></li><li><a href="#method.freebind_v6" title="freebind_v6">freebind_v6</a></li><li><a href="#method.header_included_v4" title="header_included_v4">header_included_v4</a></li><li><a href="#method.header_included_v6" title="header_included_v6">header_included_v6</a></li><li><a href="#method.ip_transparent_v4" title="ip_transparent_v4">ip_transparent_v4</a></li><li><a href="#method.is_listener" title="is_listener">is_listener</a></li><li><a href="#method.join_multicast_v4" title="join_multicast_v4">join_multicast_v4</a></li><li><a href="#method.join_multicast_v6" title="join_multicast_v6">join_multicast_v6</a></li><li><a href="#method.join_multicast_v4_n" title="join_multicast_v4_n">join_multicast_v4_n</a></li><li><a href="#method.join_ssm_v4" title="join_ssm_v4">join_ssm_v4</a></li><li><a href="#method.keepalive" title="keepalive">keepalive</a></li><li><a href="#method.leave_multicast_v4" title="leave_multicast_v4">leave_multicast_v4</a></li><li><a href="#method.leave_multicast_v6" title="leave_multicast_v6">leave_multicast_v6</a></li><li><a href="#method.leave_multicast_v4_n" title="leave_multicast_v4_n">leave_multicast_v4_n</a></li><li><a href="#method.leave_ssm_v4" title="leave_ssm_v4">leave_ssm_v4</a></li><li><a href="#method.linger" title="linger">linger</a></li><li><a href="#method.listen" title="listen">listen</a></li><li><a href="#method.local_addr" title="local_addr">local_addr</a></li><li><a href="#method.mark" title="mark">mark</a></li><li><a href="#method.multicast_all_v4" title="multicast_all_v4">multicast_all_v4</a></li><li><a href="#method.multicast_all_v6" title="multicast_all_v6">multicast_all_v6</a></li><li><a href="#method.multicast_hops_v6" title="multicast_hops_v6">multicast_hops_v6</a></li><li><a href="#method.multicast_if_v4" title="multicast_if_v4">multicast_if_v4</a></li><li><a href="#method.multicast_if_v6" title="multicast_if_v6">multicast_if_v6</a></li><li><a href="#method.multicast_loop_v4" title="multicast_loop_v4">multicast_loop_v4</a></li><li><a href="#method.multicast_loop_v6" title="multicast_loop_v6">multicast_loop_v6</a></li><li><a href="#method.multicast_ttl_v4" title="multicast_ttl_v4">multicast_ttl_v4</a></li><li><a href="#method.new" title="new">new</a></li><li><a href="#method.new_raw" title="new_raw">new_raw</a></li><li><a href="#method.nonblocking" title="nonblocking">nonblocking</a></li><li><a href="#method.only_v6" title="only_v6">only_v6</a></li><li><a href="#method.original_dst_v4" title="original_dst_v4">original_dst_v4</a></li><li><a href="#method.original_dst_v6" title="original_dst_v6">original_dst_v6</a></li><li><a href="#method.out_of_band_inline" title="out_of_band_inline">out_of_band_inline</a></li><li><a href="#method.pair" title="pair">pair</a></li><li><a href="#method.pair_raw" title="pair_raw">pair_raw</a></li><li><a href="#method.passcred" title="passcred">passcred</a></li><li><a href="#method.peek" title="peek">peek</a></li><li><a href="#method.peek_from" title="peek_from">peek_from</a></li><li><a href="#method.peek_sender" title="peek_sender">peek_sender</a></li><li><a href="#method.peer_addr" title="peer_addr">peer_addr</a></li><li><a href="#method.priority" title="priority">priority</a></li><li><a href="#method.protocol" title="protocol">protocol</a></li><li><a href="#method.read_timeout" title="read_timeout">read_timeout</a></li><li><a href="#method.recv" title="recv">recv</a></li><li><a href="#method.recv_buffer_size" title="recv_buffer_size">recv_buffer_size</a></li><li><a href="#method.recv_from" title="recv_from">recv_from</a></li><li><a href="#method.recv_from_vectored" title="recv_from_vectored">recv_from_vectored</a></li><li><a href="#method.recv_from_vectored_with_flags" title="recv_from_vectored_with_flags">recv_from_vectored_with_flags</a></li><li><a href="#method.recv_from_with_flags" title="recv_from_with_flags">recv_from_with_flags</a></li><li><a href="#method.recv_hoplimit_v6" title="recv_hoplimit_v6">recv_hoplimit_v6</a></li><li><a href="#method.recv_out_of_band" title="recv_out_of_band">recv_out_of_band</a></li><li><a href="#method.recv_tclass_v6" title="recv_tclass_v6">recv_tclass_v6</a></li><li><a href="#method.recv_tos_v4" title="recv_tos_v4">recv_tos_v4</a></li><li><a href="#method.recv_vectored" title="recv_vectored">recv_vectored</a></li><li><a href="#method.recv_vectored_with_flags" title="recv_vectored_with_flags">recv_vectored_with_flags</a></li><li><a href="#method.recv_with_flags" title="recv_with_flags">recv_with_flags</a></li><li><a href="#method.recvmsg" title="recvmsg">recvmsg</a></li><li><a href="#method.reuse_address" title="reuse_address">reuse_address</a></li><li><a href="#method.reuse_port" title="reuse_port">reuse_port</a></li><li><a href="#method.send" title="send">send</a></li><li><a href="#method.send_buffer_size" title="send_buffer_size">send_buffer_size</a></li><li><a href="#method.send_out_of_band" title="send_out_of_band">send_out_of_band</a></li><li><a href="#method.send_to" title="send_to">send_to</a></li><li><a href="#method.send_to_vectored" title="send_to_vectored">send_to_vectored</a></li><li><a href="#method.send_to_vectored_with_flags" title="send_to_vectored_with_flags">send_to_vectored_with_flags</a></li><li><a href="#method.send_to_with_flags" title="send_to_with_flags">send_to_with_flags</a></li><li><a href="#method.send_vectored" title="send_vectored">send_vectored</a></li><li><a href="#method.send_vectored_with_flags" title="send_vectored_with_flags">send_vectored_with_flags</a></li><li><a href="#method.send_with_flags" title="send_with_flags">send_with_flags</a></li><li><a href="#method.sendfile" title="sendfile">sendfile</a></li><li><a href="#method.sendmsg" title="sendmsg">sendmsg</a></li><li><a href="#method.set_broadcast" title="set_broadcast">set_broadcast</a></li><li><a href="#method.set_busy_poll" title="set_busy_poll">set_busy_poll</a></li><li><a href="#method.set_cloexec" title="set_cloexec">set_cloexec</a></li><li><a href="#method.set_cpu_affinity" title="set_cpu_affinity">set_cpu_affinity</a></li><li><a href="#method.set_dccp_ccid" title="set_dccp_ccid">set_dccp_ccid</a></li><li><a href="#method.set_dccp_qpolicy_txqlen" title="set_dccp_qpolicy_txqlen">set_dccp_qpolicy_txqlen</a></li><li><a href="#method.set_dccp_recv_cscov" title="set_dccp_recv_cscov">set_dccp_recv_cscov</a></li><li><a href="#method.set_dccp_send_cscov" title="set_dccp_send_cscov">set_dccp_send_cscov</a></li><li><a href="#method.set_dccp_server_timewait" title="set_dccp_server_timewait">set_dccp_server_timewait</a></li><li><a href="#method.set_dccp_service" title="set_dccp_service">set_dccp_service</a></li><li><a href="#method.set_freebind_v4" title="set_freebind_v4">set_freebind_v4</a></li><li><a href="#method.set_freebind_v6" title="set_freebind_v6">set_freebind_v6</a></li><li><a href="#method.set_header_included_v4" title="set_header_included_v4">set_header_included_v4</a></li><li><a href="#method.set_header_included_v6" title="set_header_included_v6">set_header_included_v6</a></li><li><a href="#method.set_ip_transparent_v4" title="set_ip_transparent_v4">set_ip_transparent_v4</a></li><li><a href="#method.set_keepalive" title="set_keepalive">set_keepalive</a></li><li><a href="#method.set_linger" title="set_linger">set_linger</a></li><li><a href="#method.set_mark" title="set_mark">set_mark</a></li><li><a href="#method.set_multicast_all_v4" title="set_multicast_all_v4">set_multicast_all_v4</a></li><li><a href="#method.set_multicast_all_v6" title="set_multicast_all_v6">set_multicast_all_v6</a></li><li><a href="#method.set_multicast_hops_v6" title="set_multicast_hops_v6">set_multicast_hops_v6</a></li><li><a href="#method.set_multicast_if_v4" title="set_multicast_if_v4">set_multicast_if_v4</a></li><li><a href="#method.set_multicast_if_v6" title="set_multicast_if_v6">set_multicast_if_v6</a></li><li><a href="#method.set_multicast_loop_v4" title="set_multicast_loop_v4">set_multicast_loop_v4</a></li><li><a href="#method.set_multicast_loop_v6" title="set_multicast_loop_v6">set_multicast_loop_v6</a></li><li><a href="#method.set_multicast_ttl_v4" title="set_multicast_ttl_v4">set_multicast_ttl_v4</a></li><li><a href="#method.set_nonblocking" title="set_nonblocking">set_nonblocking</a></li><li><a href="#method.set_only_v6" title="set_only_v6">set_only_v6</a></li><li><a href="#method.set_out_of_band_inline" title="set_out_of_band_inline">set_out_of_band_inline</a></li><li><a href="#method.set_passcred" title="set_passcred">set_passcred</a></li><li><a href="#method.set_priority" title="set_priority">set_priority</a></li><li><a href="#method.set_read_timeout" title="set_read_timeout">set_read_timeout</a></li><li><a href="#method.set_recv_buffer_size" title="set_recv_buffer_size">set_recv_buffer_size</a></li><li><a href="#method.set_recv_hoplimit_v6" title="set_recv_hoplimit_v6">set_recv_hoplimit_v6</a></li><li><a href="#method.set_recv_tclass_v6" title="set_recv_tclass_v6">set_recv_tclass_v6</a></li><li><a href="#method.set_recv_tos_v4" title="set_recv_tos_v4">set_recv_tos_v4</a></li><li><a href="#method.set_reuse_address" title="set_reuse_address">set_reuse_address</a></li><li><a href="#method.set_reuse_port" title="set_reuse_port">set_reuse_port</a></li><li><a href="#method.set_send_buffer_size" title="set_send_buffer_size">set_send_buffer_size</a></li><li><a href="#method.set_tclass_v6" title="set_tclass_v6">set_tclass_v6</a></li><li><a href="#method.set_tcp_congestion" title="set_tcp_congestion">set_tcp_congestion</a></li><li><a href="#method.set_tcp_cork" title="set_tcp_cork">set_tcp_cork</a></li><li><a href="#method.set_tcp_keepalive" title="set_tcp_keepalive">set_tcp_keepalive</a></li><li><a href="#method.set_tcp_mss" title="set_tcp_mss">set_tcp_mss</a></li><li><a href="#method.set_tcp_nodelay" title="set_tcp_nodelay">set_tcp_nodelay</a></li><li><a href="#method.set_tcp_notsent_lowat" title="set_tcp_notsent_lowat">set_tcp_notsent_lowat</a></li><li><a href="#method.set_tcp_quickack" title="set_tcp_quickack">set_tcp_quickack</a></li><li><a href="#method.set_tcp_thin_linear_timeouts" title="set_tcp_thin_linear_timeouts">set_tcp_thin_linear_timeouts</a></li><li><a href="#method.set_tcp_user_timeout" title="set_tcp_user_timeout">set_tcp_user_timeout</a></li><li><a href="#method.set_tos_v4" title="set_tos_v4">set_tos_v4</a></li><li><a href="#method.set_ttl_v4" title="set_ttl_v4">set_ttl_v4</a></li><li><a href="#method.set_unicast_hops_v6" title="set_unicast_hops_v6">set_unicast_hops_v6</a></li><li><a href="#method.set_write_timeout" title="set_write_timeout">set_write_timeout</a></li><li><a href="#method.shutdown" title="shutdown">shutdown</a></li><li><a href="#method.take_error" title="take_error">take_error</a></li><li><a href="#method.tclass_v6" title="tclass_v6">tclass_v6</a></li><li><a href="#method.tcp_congestion" title="tcp_congestion">tcp_congestion</a></li><li><a href="#method.tcp_cork" title="tcp_cork">tcp_cork</a></li><li><a href="#method.tcp_keepalive_interval" title="tcp_keepalive_interval">tcp_keepalive_interval</a></li><li><a href="#method.tcp_keepalive_retries" title="tcp_keepalive_retries">tcp_keepalive_retries</a></li><li><a href="#method.tcp_keepalive_time" title="tcp_keepalive_time">tcp_keepalive_time</a></li><li><a href="#method.tcp_mss" title="tcp_mss">tcp_mss</a></li><li><a href="#method.tcp_nodelay" title="tcp_nodelay">tcp_nodelay</a></li><li><a href="#method.tcp_notsent_lowat" title="tcp_notsent_lowat">tcp_notsent_lowat</a></li><li><a href="#method.tcp_quickack" title="tcp_quickack">tcp_quickack</a></li><li><a href="#method.tcp_thin_linear_timeouts" title="tcp_thin_linear_timeouts">tcp_thin_linear_timeouts</a></li><li><a href="#method.tcp_user_timeout" title="tcp_user_timeout">tcp_user_timeout</a></li><li><a href="#method.tos_v4" title="tos_v4">tos_v4</a></li><li><a href="#method.try_clone" title="try_clone">try_clone</a></li><li><a href="#method.ttl_v4" title="ttl_v4">ttl_v4</a></li><li><a href="#method.type" title="type">type</a></li><li><a href="#method.unicast_hops_v6" title="unicast_hops_v6">unicast_hops_v6</a></li><li><a href="#method.write_timeout" title="write_timeout">write_timeout</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-AsFd-for-Socket" title="AsFd">AsFd</a></li><li><a href="#impl-AsRawFd-for-Socket" title="AsRawFd">AsRawFd</a></li><li><a href="#impl-Debug-for-Socket" title="Debug">Debug</a></li><li><a href="#impl-From%3COwnedFd%3E-for-Socket" title="From<OwnedFd>">From<OwnedFd></a></li><li><a href="#impl-From%3CSocket%3E-for-OwnedFd" title="From<Socket>">From<Socket></a></li><li><a href="#impl-From%3CSocket%3E-for-TcpListener" title="From<Socket>">From<Socket></a></li><li><a href="#impl-From%3CSocket%3E-for-TcpStream" title="From<Socket>">From<Socket></a></li><li><a href="#impl-From%3CSocket%3E-for-UdpSocket" title="From<Socket>">From<Socket></a></li><li><a href="#impl-From%3CSocket%3E-for-UnixDatagram" title="From<Socket>">From<Socket></a></li><li><a href="#impl-From%3CSocket%3E-for-UnixListener" title="From<Socket>">From<Socket></a></li><li><a href="#impl-From%3CSocket%3E-for-UnixStream" title="From<Socket>">From<Socket></a></li><li><a href="#impl-From%3CTcpListener%3E-for-Socket" title="From<TcpListener>">From<TcpListener></a></li><li><a href="#impl-From%3CTcpStream%3E-for-Socket" title="From<TcpStream>">From<TcpStream></a></li><li><a href="#impl-From%3CUdpSocket%3E-for-Socket" title="From<UdpSocket>">From<UdpSocket></a></li><li><a href="#impl-From%3CUnixDatagram%3E-for-Socket" title="From<UnixDatagram>">From<UnixDatagram></a></li><li><a href="#impl-From%3CUnixListener%3E-for-Socket" title="From<UnixListener>">From<UnixListener></a></li><li><a href="#impl-From%3CUnixStream%3E-for-Socket" title="From<UnixStream>">From<UnixStream></a></li><li><a href="#impl-FromRawFd-for-Socket" title="FromRawFd">FromRawFd</a></li><li><a href="#impl-IntoRawFd-for-Socket" title="IntoRawFd">IntoRawFd</a></li><li><a href="#impl-Read-for-%26Socket" title="Read">Read</a></li><li><a href="#impl-Read-for-Socket" title="Read">Read</a></li><li><a href="#impl-Write-for-%26Socket" title="Write">Write</a></li><li><a href="#impl-Write-for-Socket" title="Write">Write</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Socket" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Socket" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Socket" title="Send">Send</a></li><li><a href="#impl-Sync-for-Socket" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Socket" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Socket" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate socket2</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">socket2</a></div><h1>Struct <span class="struct">Socket</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/socket2/socket.rs.html#75-77">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Socket { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Owned wrapper around a system socket.</p>
|
||
<p>This type simply wraps an instance of a file descriptor (<code>c_int</code>) on Unix
|
||
and an instance of <code>SOCKET</code> on Windows. This is the main type exported by
|
||
this crate and is intended to mirror the raw semantics of sockets on
|
||
platforms as closely as possible. Almost all methods correspond to
|
||
precisely one libc or OS API call which is essentially just a “Rustic
|
||
translation” of what’s below.</p>
|
||
<h3 id="converting-to-and-from-other-types"><a class="doc-anchor" href="#converting-to-and-from-other-types">§</a>Converting to and from other types</h3>
|
||
<p>This type can be freely converted into the network primitives provided by
|
||
the standard library, such as <a href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream"><code>TcpStream</code></a> or <a href="https://doc.rust-lang.org/1.93.1/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket"><code>UdpSocket</code></a>, using the
|
||
<a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From"><code>From</code></a> trait, see the example below.</p>
|
||
<h2 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h2>
|
||
<p>Some methods that set options on <code>Socket</code> require two system calls to set
|
||
their options without overwriting previously set options. We do this by
|
||
first getting the current settings, applying the desired changes, and then
|
||
updating the settings. This means that the operation is <strong>not</strong> atomic. This
|
||
can lead to a data race when two threads are changing options in parallel.</p>
|
||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::net::{SocketAddr, TcpListener};
|
||
<span class="kw">use </span>socket2::{Socket, Domain, Type};
|
||
|
||
<span class="comment">// create a TCP listener
|
||
</span><span class="kw">let </span>socket = Socket::new(Domain::IPV6, Type::STREAM, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
|
||
|
||
<span class="kw">let </span>address: SocketAddr = <span class="string">"[::1]:12345"</span>.parse().unwrap();
|
||
<span class="kw">let </span>address = address.into();
|
||
socket.bind(<span class="kw-2">&</span>address)<span class="question-mark">?</span>;
|
||
socket.listen(<span class="number">128</span>)<span class="question-mark">?</span>;
|
||
|
||
<span class="kw">let </span>listener: TcpListener = socket.into();
|
||
<span class="comment">// ...</span></code></pre></div></div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#79-736">Source</a><a href="#impl-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#115-118">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(
|
||
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
|
||
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
|
||
protocol: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>></h4></section></summary><div class="docblock"><p>Creates a new socket and sets common flags.</p>
|
||
<p>This function corresponds to <code>socket(2)</code> on Unix and <code>WSASocketW</code> on
|
||
Windows.</p>
|
||
<p>On Unix-like systems, the close-on-exec flag is set on the new socket.
|
||
Additionally, on Apple platforms <code>SOCK_NOSIGPIPE</code> is set. On Windows,
|
||
the socket is made non-inheritable.</p>
|
||
<p><a href="struct.Socket.html#method.new_raw" title="associated function socket2::Socket::new_raw"><code>Socket::new_raw</code></a> can be used if you don’t want these flags to be set.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=socket&section=2">https://man.dragonflybsd.org/?command=socket&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=socket&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=socket&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/socket.2.html">https://man7.org/linux/man-pages/man2/socket.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/socket.2">https://man.netbsd.org/socket.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/socket.2">https://man.openbsd.org/socket.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socket.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/socket">https://illumos.org/man/3SOCKET/socket</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.new_raw" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#124-127">Source</a><h4 class="code-header">pub fn <a href="#method.new_raw" class="fn">new_raw</a>(
|
||
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
|
||
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
|
||
protocol: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>></h4></section></summary><div class="docblock"><p>Creates a new socket ready to be configured.</p>
|
||
<p>This function corresponds to <code>socket(2)</code> on Unix and <code>WSASocketW</code> on
|
||
Windows and simply creates a new socket, no other configuration is done.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.pair" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#137-147">Source</a><h4 class="code-header">pub fn <a href="#method.pair" class="fn">pair</a>(
|
||
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
|
||
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
|
||
protocol: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>)></h4></section></summary><div class="docblock"><p>Creates a pair of sockets which are connected to each other.</p>
|
||
<p>This function corresponds to <code>socketpair(2)</code>.</p>
|
||
<p>This function sets the same flags as in done for <a href="struct.Socket.html#method.new" title="associated function socket2::Socket::new"><code>Socket::new</code></a>,
|
||
<a href="struct.Socket.html#method.pair_raw" title="associated function socket2::Socket::pair_raw"><code>Socket::pair_raw</code></a> can be used if you don’t want to set those flags.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=socketpair&section=2">https://man.dragonflybsd.org/?command=socketpair&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=socketpair&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=socketpair&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/socketpair.2.html">https://man7.org/linux/man-pages/man2/socketpair.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/socketpair.2">https://man.netbsd.org/socketpair.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/socketpair.2">https://man.openbsd.org/socketpair.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/socketpair">https://illumos.org/man/3SOCKET/socketpair</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.pair_raw" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#153-161">Source</a><h4 class="code-header">pub fn <a href="#method.pair_raw" class="fn">pair_raw</a>(
|
||
domain: <a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>,
|
||
ty: <a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>,
|
||
protocol: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>)></h4></section></summary><div class="docblock"><p>Creates a pair of sockets which are connected to each other.</p>
|
||
<p>This function corresponds to <code>socketpair(2)</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#168-170">Source</a><h4 class="code-header">pub fn <a href="#method.bind" class="fn">bind</a>(&self, address: &<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Binds this socket to the specified address.</p>
|
||
<p>This function directly corresponds to the <code>bind(2)</code> function on Windows
|
||
and Unix.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=bind&section=2">https://man.dragonflybsd.org/?command=bind&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=bind&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=bind&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/bind.2.html">https://man7.org/linux/man-pages/man2/bind.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/bind.2">https://man.netbsd.org/bind.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/bind.2">https://man.openbsd.org/bind.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/bind.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/bind">https://illumos.org/man/3SOCKET/bind</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.connect" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#192-194">Source</a><h4 class="code-header">pub fn <a href="#method.connect" class="fn">connect</a>(&self, address: &<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Initiate a connection on this socket to the specified address.</p>
|
||
<p>This function directly corresponds to the <code>connect(2)</code> function on
|
||
Windows and Unix.</p>
|
||
<p>An error will be returned if <code>listen</code> or <code>connect</code> has already been
|
||
called on this builder.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=connect&section=2">https://man.dragonflybsd.org/?command=connect&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=connect&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=connect&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/connect.2.html">https://man7.org/linux/man-pages/man2/connect.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/connect.2">https://man.netbsd.org/connect.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/connect.2">https://man.openbsd.org/connect.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/connect">https://illumos.org/man/3SOCKET/connect</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect</a></li>
|
||
</ul>
|
||
<h5 id="notes-1"><a class="doc-anchor" href="#notes-1">§</a>Notes</h5>
|
||
<p>When using a non-blocking connect (by setting the socket into
|
||
non-blocking mode before calling this function), socket option can’t be
|
||
set <em>while connecting</em>. This will cause errors on Windows. Socket
|
||
options can be safely set before and after connecting the socket.</p>
|
||
<p>On Cygwin, a Unix domain socket connect blocks until the server accepts
|
||
it. If the behavior is not expected, try [<code>Socket::set_no_peercred</code>]
|
||
(Cygwin only).</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.connect_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#215-229">Source</a><h4 class="code-header">pub fn <a href="#method.connect_timeout" class="fn">connect_timeout</a>(&self, addr: &<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>, timeout: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Initiate a connection on this socket to the specified address, only
|
||
only waiting for a certain period of time for the connection to be
|
||
established.</p>
|
||
<p>Unlike many other methods on <code>Socket</code>, this does <em>not</em> correspond to a
|
||
single C function. It sets the socket to nonblocking mode, connects via
|
||
connect(2), and then waits for the connection to complete with poll(2)
|
||
on Unix and select on Windows. When the connection is complete, the
|
||
socket is set back to blocking mode. On Unix, this will loop over
|
||
<code>EINTR</code> errors.</p>
|
||
<h5 id="warnings"><a class="doc-anchor" href="#warnings">§</a>Warnings</h5>
|
||
<p>The non-blocking state of the socket is overridden by this function -
|
||
it will be returned in blocking mode on success, and in an indeterminate
|
||
state on failure.</p>
|
||
<p>If the connection request times out, it may still be processing in the
|
||
background - a second call to <code>connect</code> or <code>connect_timeout</code> may fail.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.listen" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#240-242">Source</a><h4 class="code-header">pub fn <a href="#method.listen" class="fn">listen</a>(&self, backlog: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Mark a socket as ready to accept incoming connection requests using
|
||
<a href="struct.Socket.html#method.accept" title="method socket2::Socket::accept"><code>Socket::accept()</code></a>.</p>
|
||
<p>This function directly corresponds to the <code>listen(2)</code> function on
|
||
Windows and Unix.</p>
|
||
<p>An error will be returned if <code>listen</code> or <code>connect</code> has already been
|
||
called on this builder.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=listen&section=2">https://man.dragonflybsd.org/?command=listen&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=listen&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=listen&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/listen.2.html">https://man7.org/linux/man-pages/man2/listen.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/listen.2">https://man.netbsd.org/listen.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/listen.2">https://man.openbsd.org/listen.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/listen.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/listen">https://illumos.org/man/3SOCKET/listen</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.accept" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#259-295">Source</a><h4 class="code-header">pub fn <a href="#method.accept" class="fn">accept</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Accept a new incoming connection from this listener.</p>
|
||
<p>This function uses <code>accept4(2)</code> on platforms that support it and
|
||
<code>accept(2)</code> platforms that do not.</p>
|
||
<p>This function sets the same flags as in done for <a href="struct.Socket.html#method.new" title="associated function socket2::Socket::new"><code>Socket::new</code></a>,
|
||
<a href="struct.Socket.html#method.accept_raw" title="method socket2::Socket::accept_raw"><code>Socket::accept_raw</code></a> can be used if you don’t want to set those flags.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=accept&section=2">https://man.dragonflybsd.org/?command=accept&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=accept&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=accept&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/accept.2.html">https://man7.org/linux/man-pages/man2/accept.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/accept.2">https://man.netbsd.org/accept.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/accept.2">https://man.openbsd.org/accept.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/accept">https://illumos.org/man/3SOCKET/accept</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept</a></li>
|
||
</ul>
|
||
<h5 id="notes-2"><a class="doc-anchor" href="#notes-2">§</a>Notes</h5>
|
||
<p>On Cygwin, a Unix domain socket connect blocks until the server accepts
|
||
it. If the behavior is not expected, try [<code>Socket::set_no_peercred</code>]
|
||
(Cygwin only).</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.accept_raw" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#301-303">Source</a><h4 class="code-header">pub fn <a href="#method.accept_raw" class="fn">accept_raw</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Accept a new incoming connection from this listener.</p>
|
||
<p>This function directly corresponds to the <code>accept(2)</code> function on
|
||
Windows and Unix.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.local_addr" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#317-319">Source</a><h4 class="code-header">pub fn <a href="#method.local_addr" class="fn">local_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>></h4></section></summary><div class="docblock"><p>Returns the socket address of the local half of this socket.</p>
|
||
<p>This function directly corresponds to the <code>getsockname(2)</code> function on
|
||
Windows and Unix.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=getsockname&section=2">https://man.dragonflybsd.org/?command=getsockname&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=getsockname&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=getsockname&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/getsockname.2.html">https://man7.org/linux/man-pages/man2/getsockname.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/getsockname.2">https://man.netbsd.org/getsockname.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/getsockname.2">https://man.openbsd.org/getsockname.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockname.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/getsockname">https://illumos.org/man/3SOCKET/getsockname</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname</a></li>
|
||
</ul>
|
||
<h5 id="notes-3"><a class="doc-anchor" href="#notes-3">§</a>Notes</h5>
|
||
<p>Depending on the OS this may return an error if the socket is not
|
||
<a href="struct.Socket.html#method.bind" title="method socket2::Socket::bind">bound</a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.peer_addr" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#332-334">Source</a><h4 class="code-header">pub fn <a href="#method.peer_addr" class="fn">peer_addr</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>></h4></section></summary><div class="docblock"><p>Returns the socket address of the remote peer of this socket.</p>
|
||
<p>This function directly corresponds to the <code>getpeername(2)</code> function on
|
||
Windows and Unix.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=getpeername&section=2">https://man.dragonflybsd.org/?command=getpeername&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=getpeername&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/getpeername.2.html">https://man7.org/linux/man-pages/man2/getpeername.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/getpeername.2">https://man.netbsd.org/getpeername.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/getpeername.2">https://man.openbsd.org/getpeername.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpeername.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/getpeername">https://illumos.org/man/3SOCKET/getpeername</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getpeername">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getpeername</a></li>
|
||
</ul>
|
||
<h5 id="notes-4"><a class="doc-anchor" href="#notes-4">§</a>Notes</h5>
|
||
<p>This returns an error if the socket is not <a href="struct.Socket.html#method.connect" title="method socket2::Socket::connect"><code>connect</code>ed</a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.type" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#338-340">Source</a><h4 class="code-header">pub fn <a href="#method.type" class="fn">type</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.Type.html" title="struct socket2::Type">Type</a>></h4></section></summary><div class="docblock"><p>Returns the <a href="struct.Type.html" title="struct socket2::Type"><code>Type</code></a> of this socket by checking the <code>SO_TYPE</code> option on
|
||
this socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_clone" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#355-357">Source</a><h4 class="code-header">pub fn <a href="#method.try_clone" class="fn">try_clone</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>></h4></section></summary><div class="docblock"><p>Creates a new independently owned handle to the underlying socket.</p>
|
||
<h5 id="notes-5"><a class="doc-anchor" href="#notes-5">§</a>Notes</h5>
|
||
<p>On Unix this uses <code>F_DUPFD_CLOEXEC</code> and thus sets the <code>FD_CLOEXEC</code> on
|
||
the returned socket.</p>
|
||
<p>On Windows this uses <code>WSA_FLAG_NO_HANDLE_INHERIT</code> setting inheriting to
|
||
false.</p>
|
||
<p>On Windows this can <strong>not</strong> be used function cannot be used on a
|
||
QOS-enabled socket, see
|
||
<a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw</a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.nonblocking" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#368-370">Source</a><h4 class="code-header">pub fn <a href="#method.nonblocking" class="fn">nonblocking</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Returns true if this socket is set to nonblocking mode, false otherwise.</p>
|
||
<h5 id="notes-6"><a class="doc-anchor" href="#notes-6">§</a>Notes</h5>
|
||
<p>On Unix this corresponds to calling <code>fcntl</code> returning the value of
|
||
<code>O_NONBLOCK</code>.</p>
|
||
<p>On Windows it is not possible retrieve the nonblocking mode status.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_nonblocking" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#380-382">Source</a><h4 class="code-header">pub fn <a href="#method.set_nonblocking" class="fn">set_nonblocking</a>(&self, nonblocking: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Moves this socket into or out of nonblocking mode.</p>
|
||
<h5 id="notes-7"><a class="doc-anchor" href="#notes-7">§</a>Notes</h5>
|
||
<p>On Unix this corresponds to calling <code>fcntl</code> (un)setting <code>O_NONBLOCK</code>.</p>
|
||
<p>On Windows this corresponds to calling <code>ioctlsocket</code> (un)setting
|
||
<code>FIONBIO</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.shutdown" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#389-391">Source</a><h4 class="code-header">pub fn <a href="#method.shutdown" class="fn">shutdown</a>(&self, how: <a class="enum" href="https://doc.rust-lang.org/1.93.1/std/net/enum.Shutdown.html" title="enum std::net::Shutdown">Shutdown</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Shuts down the read, write, or both halves of this connection.</p>
|
||
<p>This function will cause all pending and future I/O on the specified
|
||
portions to return immediately with an appropriate value.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=shutdown&section=2">https://man.dragonflybsd.org/?command=shutdown&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=shutdown&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/shutdown.2.html">https://man7.org/linux/man-pages/man2/shutdown.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/shutdown.2">https://man.netbsd.org/shutdown.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/shutdown.2">https://man.openbsd.org/shutdown.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shutdown.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/shutdown">https://illumos.org/man/3SOCKET/shutdown</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-shutdown</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#414-416">Source</a><h4 class="code-header">pub fn <a href="#method.recv" class="fn">recv</a>(&self, buf: &mut [<a class="union" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/std/primitive.u8.html">u8</a>>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||
connected.</p>
|
||
<p>The <a href="struct.Socket.html#method.connect" title="method socket2::Socket::connect"><code>connect</code></a> method will connect this socket to a remote address.
|
||
This method might fail if the socket is not connected.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recv&section=2">https://man.dragonflybsd.org/?command=recv&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recv&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recv&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recv.2.html">https://man7.org/linux/man-pages/man2/recv.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/recv.2">https://man.netbsd.org/recv.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/recv.2">https://man.openbsd.org/recv.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recv.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recv">https://illumos.org/man/3SOCKET/recv</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv</a></li>
|
||
</ul>
|
||
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
|
||
<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/1.93.1/std/io/trait.Read.html#tymethod.read" title="method std::io::Read::read"><code>io::Read::read</code></a> implementation calls this function with
|
||
a <code>buf</code>fer of type <code>&mut [u8]</code>, allowing initialised buffers to be used
|
||
without using <code>unsafe</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_out_of_band" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#426-428">Source</a><h4 class="code-header">pub fn <a href="#method.recv_out_of_band" class="fn">recv_out_of_band</a>(&self, buf: &mut [<a class="union" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/std/primitive.u8.html">u8</a>>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Receives out-of-band (OOB) data on the socket from the remote address to
|
||
which it is connected by setting the <code>MSG_OOB</code> flag for this call.</p>
|
||
<p>For more information, see <a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>, <a href="struct.Socket.html#method.out_of_band_inline" title="method socket2::Socket::out_of_band_inline"><code>out_of_band_inline</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#434-440">Source</a><h4 class="code-header">pub fn <a href="#method.recv_with_flags" class="fn">recv_with_flags</a>(
|
||
&self,
|
||
buf: &mut [<a class="union" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/std/primitive.u8.html">u8</a>>],
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a> but allows for specification of arbitrary flags to
|
||
the underlying <code>recv</code> call.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#469-474">Source</a><h4 class="code-header">pub fn <a href="#method.recv_vectored" class="fn">recv_vectored</a>(
|
||
&self,
|
||
bufs: &mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_>],
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>)></h4></section></summary><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||
connected. Unlike <a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a> this allows passing multiple buffers.</p>
|
||
<p>The <a href="struct.Socket.html#method.connect" title="method socket2::Socket::connect"><code>connect</code></a> method will connect this socket to a remote address.
|
||
This method might fail if the socket is not connected.</p>
|
||
<p>In addition to the number of bytes read, this function returns the flags
|
||
for the received message. See <a href="struct.RecvFlags.html" title="struct socket2::RecvFlags"><code>RecvFlags</code></a> for more information about
|
||
the returned flags.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvmsg&section=2">https://man.dragonflybsd.org/?command=recvmsg&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvmsg&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvmsg&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvmsg.2.html">https://man7.org/linux/man-pages/man2/recvmsg.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/recvmsg.2">https://man.netbsd.org/recvmsg.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/recvmsg.2">https://man.openbsd.org/recvmsg.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvmsg">https://illumos.org/man/3SOCKET/recvmsg</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg</a></li>
|
||
</ul>
|
||
<h5 id="safety-1"><a class="doc-anchor" href="#safety-1">§</a>Safety</h5>
|
||
<p>Normally casting a <code>IoSliceMut</code> to <code>MaybeUninitSlice</code> would be unsound,
|
||
as that allows us to write uninitialised bytes to the buffer. However
|
||
this implementation promises to not write uninitialised bytes to the
|
||
<code>bufs</code> and passes it directly to <code>recvmsg(2)</code> system call. This promise
|
||
ensures that this function can be called using <code>bufs</code> of type <code>&mut [IoSliceMut]</code>.</p>
|
||
<p>Note that the <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_vectored" title="method std::io::Read::read_vectored"><code>io::Read::read_vectored</code></a> implementation calls this
|
||
function with <code>buf</code>s of type <code>&mut [IoSliceMut]</code>, allowing initialised
|
||
buffers to be used without using <code>unsafe</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#488-494">Source</a><h4 class="code-header">pub fn <a href="#method.recv_vectored_with_flags" class="fn">recv_vectored_with_flags</a>(
|
||
&self,
|
||
bufs: &mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_>],
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>)></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a> but allows for specification of arbitrary
|
||
flags to the underlying <code>recvmsg</code>/<code>WSARecv</code> call.</p>
|
||
<h5 id="safety-2"><a class="doc-anchor" href="#safety-2">§</a>Safety</h5>
|
||
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
|
||
as <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.peek" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#509-511">Source</a><h4 class="code-header">pub fn <a href="#method.peek" class="fn">peek</a>(&self, buf: &mut [<a class="union" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/std/primitive.u8.html">u8</a>>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Receives data on the socket from the remote address to which it is
|
||
connected, without removing that data from the queue. On success,
|
||
returns the number of bytes peeked.</p>
|
||
<p>Successive calls return the same data. This is accomplished by passing
|
||
<code>MSG_PEEK</code> as a flag to the underlying <code>recv</code> system call.</p>
|
||
<h5 id="safety-3"><a class="doc-anchor" href="#safety-3">§</a>Safety</h5>
|
||
<p><code>peek</code> makes the same safety guarantees regarding the <code>buf</code>fer as
|
||
<a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#523-525">Source</a><h4 class="code-header">pub fn <a href="#method.recv_from" class="fn">recv_from</a>(
|
||
&self,
|
||
buf: &mut [<a class="union" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/std/primitive.u8.html">u8</a>>],
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Receives data from the socket. On success, returns the number of bytes
|
||
read and the address from whence the data came.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvfrom&section=2">https://man.dragonflybsd.org/?command=recvfrom&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvfrom&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvfrom&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvfrom.2.html">https://man7.org/linux/man-pages/man2/recvfrom.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/recvfrom.2">https://man.netbsd.org/recvfrom.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/recvfrom.2">https://man.openbsd.org/recvfrom.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvfrom.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvfrom">https://illumos.org/man/3SOCKET/recvfrom</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom</a></li>
|
||
</ul>
|
||
<h5 id="safety-4"><a class="doc-anchor" href="#safety-4">§</a>Safety</h5>
|
||
<p><code>recv_from</code> makes the same safety guarantees regarding the <code>buf</code>fer as
|
||
<a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#531-537">Source</a><h4 class="code-header">pub fn <a href="#method.recv_from_with_flags" class="fn">recv_from_with_flags</a>(
|
||
&self,
|
||
buf: &mut [<a class="union" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/std/primitive.u8.html">u8</a>>],
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv_from" title="method socket2::Socket::recv_from"><code>recv_from</code></a> but allows for specification of arbitrary
|
||
flags to the underlying <code>recvfrom</code> call.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#553-558">Source</a><h4 class="code-header">pub fn <a href="#method.recv_from_vectored" class="fn">recv_from_vectored</a>(
|
||
&self,
|
||
bufs: &mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_>],
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Receives data from the socket. Returns the amount of bytes read, the
|
||
<a href="struct.RecvFlags.html" title="struct socket2::RecvFlags"><code>RecvFlags</code></a> and the remote address from the data is coming. Unlike
|
||
<a href="struct.Socket.html#method.recv_from" title="method socket2::Socket::recv_from"><code>recv_from</code></a> this allows passing multiple buffers.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvmsg&section=2">https://man.dragonflybsd.org/?command=recvmsg&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvmsg&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvmsg&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvmsg.2.html">https://man7.org/linux/man-pages/man2/recvmsg.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/recvmsg.2">https://man.netbsd.org/recvmsg.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/recvmsg.2">https://man.openbsd.org/recvmsg.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvmsg">https://illumos.org/man/3SOCKET/recvmsg</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg</a></li>
|
||
</ul>
|
||
<h5 id="safety-5"><a class="doc-anchor" href="#safety-5">§</a>Safety</h5>
|
||
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
|
||
as <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_from_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#572-578">Source</a><h4 class="code-header">pub fn <a href="#method.recv_from_vectored_with_flags" class="fn">recv_from_vectored_with_flags</a>(
|
||
&self,
|
||
bufs: &mut [<a class="struct" href="struct.MaybeUninitSlice.html" title="struct socket2::MaybeUninitSlice">MaybeUninitSlice</a><'_>],
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.RecvFlags.html" title="struct socket2::RecvFlags">RecvFlags</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.recv_from_vectored" title="method socket2::Socket::recv_from_vectored"><code>recv_from_vectored</code></a> but allows for specification of
|
||
arbitrary flags to the underlying <code>recvmsg</code>/<code>WSARecvFrom</code> call.</p>
|
||
<h5 id="safety-6"><a class="doc-anchor" href="#safety-6">§</a>Safety</h5>
|
||
<p><code>recv_from_vectored</code> makes the same safety guarantees regarding <code>bufs</code>
|
||
as <a href="struct.Socket.html#method.recv_vectored" title="method socket2::Socket::recv_vectored"><code>recv_vectored</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.peek_from" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#609-611">Source</a><h4 class="code-header">pub fn <a href="#method.peek_from" class="fn">peek_from</a>(
|
||
&self,
|
||
buf: &mut [<a class="union" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/std/primitive.u8.html">u8</a>>],
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Receives data from the socket, without removing it from the queue.</p>
|
||
<p>Successive calls return the same data. This is accomplished by passing
|
||
<code>MSG_PEEK</code> as a flag to the underlying <code>recvfrom</code> system call.</p>
|
||
<p>On success, returns the number of bytes peeked and the address from
|
||
whence the data came.</p>
|
||
<h5 id="safety-7"><a class="doc-anchor" href="#safety-7">§</a>Safety</h5>
|
||
<p><code>peek_from</code> makes the same safety guarantees regarding the <code>buf</code>fer as
|
||
<a href="struct.Socket.html#method.recv" title="method socket2::Socket::recv"><code>recv</code></a>.</p>
|
||
<h5 id="note-datagram-sockets"><a class="doc-anchor" href="#note-datagram-sockets">§</a>Note: Datagram Sockets</h5>
|
||
<p>For datagram sockets, the behavior of this method when <code>buf</code> is smaller than
|
||
the datagram at the head of the receive queue differs between Windows and
|
||
Unix-like platforms (Linux, macOS, BSDs, etc: colloquially termed “*nix”).</p>
|
||
<p>On *nix platforms, the datagram is truncated to the length of <code>buf</code>.</p>
|
||
<p>On Windows, an error corresponding to <code>WSAEMSGSIZE</code> will be returned.</p>
|
||
<p>For consistency between platforms, be sure to provide a sufficiently large buffer to avoid
|
||
truncation; the exact size required depends on the underlying protocol.</p>
|
||
<p>If you just want to know the sender of the data, try <a href="struct.Socket.html#method.peek_sender" title="method socket2::Socket::peek_sender"><code>peek_sender</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.peek_sender" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#619-621">Source</a><h4 class="code-header">pub fn <a href="#method.peek_sender" class="fn">peek_sender</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>></h4></section></summary><div class="docblock"><p>Retrieve the sender for the data at the head of the receive queue.</p>
|
||
<p>This is equivalent to calling <a href="struct.Socket.html#method.peek_from" title="method socket2::Socket::peek_from"><code>peek_from</code></a> with a zero-sized buffer,
|
||
but suppresses the <code>WSAEMSGSIZE</code> error on Windows.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recvmsg" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#631-633">Source</a><h4 class="code-header">pub fn <a href="#method.recvmsg" class="fn">recvmsg</a>(
|
||
&self,
|
||
msg: &mut <a class="struct" href="struct.MsgHdrMut.html" title="struct socket2::MsgHdrMut">MsgHdrMut</a><'_, '_, '_>,
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Receive a message from a socket using a message structure.</p>
|
||
<p>This is not supported on Windows as calling <code>WSARecvMsg</code> (the <code>recvmsg</code>
|
||
equivalent) is not straight forward on Windows. See
|
||
<a href="https://github.com/microsoft/Windows-classic-samples/blob/7cbd99ac1d2b4a0beffbaba29ea63d024ceff700/Samples/Win7Samples/netds/winsock/recvmsg/rmmc.cpp">https://github.com/microsoft/Windows-classic-samples/blob/7cbd99ac1d2b4a0beffbaba29ea63d024ceff700/Samples/Win7Samples/netds/winsock/recvmsg/rmmc.cpp</a>
|
||
for an example (in C++).</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=recvmsg&section=2">https://man.dragonflybsd.org/?command=recvmsg&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=recvmsg&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=recvmsg&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/recvmsg.2.html">https://man7.org/linux/man-pages/man2/recvmsg.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/recvmsg.2">https://man.netbsd.org/recvmsg.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/recvmsg.2">https://man.openbsd.org/recvmsg.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/recvmsg.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/recvmsg">https://illumos.org/man/3SOCKET/recvmsg</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvmsg</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#642-644">Source</a><h4 class="code-header">pub fn <a href="#method.send" class="fn">send</a>(&self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Sends data on the socket to a connected peer.</p>
|
||
<p>This is typically used on TCP sockets or datagram sockets which have
|
||
been connected.</p>
|
||
<p>On success returns the number of bytes that were sent.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=send&section=2">https://man.dragonflybsd.org/?command=send&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=send&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=send&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/send.2.html">https://man7.org/linux/man-pages/man2/send.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/send.2">https://man.netbsd.org/send.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/send.2">https://man.openbsd.org/send.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/send.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/send">https://illumos.org/man/3SOCKET/send</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#650-652">Source</a><h4 class="code-header">pub fn <a href="#method.send_with_flags" class="fn">send_with_flags</a>(&self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>], flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send" title="method socket2::Socket::send"><code>send</code></a> but allows for specification of arbitrary flags to the underlying
|
||
<code>send</code> call.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#656-658">Source</a><h4 class="code-header">pub fn <a href="#method.send_vectored" class="fn">send_vectored</a>(&self, bufs: &[<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Send data to the connected peer. Returns the amount of bytes written.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#666-672">Source</a><h4 class="code-header">pub fn <a href="#method.send_vectored_with_flags" class="fn">send_vectored_with_flags</a>(
|
||
&self,
|
||
bufs: &[<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>],
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send_vectored" title="method socket2::Socket::send_vectored"><code>send_vectored</code></a> but allows for specification of arbitrary
|
||
flags to the underlying <code>sendmsg</code>/<code>WSASend</code> call.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendmsg&section=2">https://man.dragonflybsd.org/?command=sendmsg&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendmsg&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendmsg&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendmsg.2.html">https://man7.org/linux/man-pages/man2/sendmsg.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/sendmsg.2">https://man.netbsd.org/sendmsg.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/sendmsg.2">https://man.openbsd.org/sendmsg.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendmsg">https://illumos.org/man/3SOCKET/sendmsg</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_out_of_band" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#682-684">Source</a><h4 class="code-header">pub fn <a href="#method.send_out_of_band" class="fn">send_out_of_band</a>(&self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Sends out-of-band (OOB) data on the socket to connected peer
|
||
by setting the <code>MSG_OOB</code> flag for this call.</p>
|
||
<p>For more information, see <a href="struct.Socket.html#method.send" title="method socket2::Socket::send"><code>send</code></a>, <a href="struct.Socket.html#method.out_of_band_inline" title="method socket2::Socket::out_of_band_inline"><code>out_of_band_inline</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#691-693">Source</a><h4 class="code-header">pub fn <a href="#method.send_to" class="fn">send_to</a>(&self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>], addr: &<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Sends data on the socket to the given address. On success, returns the
|
||
number of bytes written.</p>
|
||
<p>This is typically used on UDP or datagram-oriented sockets.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendto&section=2">https://man.dragonflybsd.org/?command=sendto&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendto&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendto&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendto.2.html">https://man7.org/linux/man-pages/man2/sendto.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/sendto.2">https://man.netbsd.org/sendto.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/sendto.2">https://man.openbsd.org/sendto.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendto.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendto">https://illumos.org/man/3SOCKET/sendto</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#699-706">Source</a><h4 class="code-header">pub fn <a href="#method.send_to_with_flags" class="fn">send_to_with_flags</a>(
|
||
&self,
|
||
buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>],
|
||
addr: &<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>,
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send_to" title="method socket2::Socket::send_to"><code>send_to</code></a> but allows for specification of arbitrary flags
|
||
to the underlying <code>sendto</code> call.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to_vectored" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#712-714">Source</a><h4 class="code-header">pub fn <a href="#method.send_to_vectored" class="fn">send_to_vectored</a>(
|
||
&self,
|
||
bufs: &[<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>],
|
||
addr: &<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Send data to a peer listening on <code>addr</code>. Returns the amount of bytes
|
||
written.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendmsg&section=2">https://man.dragonflybsd.org/?command=sendmsg&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendmsg&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendmsg&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendmsg.2.html">https://man7.org/linux/man-pages/man2/sendmsg.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/sendmsg.2">https://man.netbsd.org/sendmsg.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/sendmsg.2">https://man.openbsd.org/sendmsg.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendmsg">https://illumos.org/man/3SOCKET/sendmsg</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_to_vectored_with_flags" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#721-728">Source</a><h4 class="code-header">pub fn <a href="#method.send_to_vectored_with_flags" class="fn">send_to_vectored_with_flags</a>(
|
||
&self,
|
||
bufs: &[<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>],
|
||
addr: &<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>,
|
||
flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Identical to <a href="struct.Socket.html#method.send_to_vectored" title="method socket2::Socket::send_to_vectored"><code>send_to_vectored</code></a> but allows for specification of
|
||
arbitrary flags to the underlying <code>sendmsg</code>/<code>WSASendTo</code> call.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.sendmsg" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#733-735">Source</a><h4 class="code-header">pub fn <a href="#method.sendmsg" class="fn">sendmsg</a>(&self, msg: &<a class="struct" href="struct.MsgHdr.html" title="struct socket2::MsgHdr">MsgHdr</a><'_, '_, '_>, flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Send a message on a socket using a message structure.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendmsg&section=2">https://man.dragonflybsd.org/?command=sendmsg&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendmsg&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendmsg&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendmsg.2.html">https://man7.org/linux/man-pages/man2/sendmsg.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/sendmsg.2">https://man.netbsd.org/sendmsg.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/sendmsg.2">https://man.openbsd.org/sendmsg.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendmsg.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendmsg">https://illumos.org/man/3SOCKET/sendmsg</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg">https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendmsg</a></li>
|
||
</ul>
|
||
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-1" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#865-1171">Source</a><a href="#impl-Socket-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3><div class="docblock"><p>Socket options get/set using <code>SOL_SOCKET</code>.</p>
|
||
</div></section></summary><div class="docblock"><p>Additional documentation can be found in documentation of the OS.</p>
|
||
<ul>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/socket.7.html">https://man7.org/linux/man-pages/man7/socket.7.html</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options</a></li>
|
||
</ul>
|
||
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.broadcast" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#871-876">Source</a><h4 class="code-header">pub fn <a href="#method.broadcast" class="fn">broadcast</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_BROADCAST</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_broadcast" title="method socket2::Socket::set_broadcast"><code>set_broadcast</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_broadcast" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#882-891">Source</a><h4 class="code-header">pub fn <a href="#method.set_broadcast" class="fn">set_broadcast</a>(&self, broadcast: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>SO_BROADCAST</code> option for this socket.</p>
|
||
<p>When enabled, this socket is allowed to send packets to a broadcast
|
||
address.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.take_error" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#898-904">Source</a><h4 class="code-header">pub fn <a href="#method.take_error" class="fn">take_error</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_ERROR</code> option on this socket.</p>
|
||
<p>This will retrieve the stored error in the underlying socket, clearing
|
||
the field in the process. This can be useful for checking errors between
|
||
calls.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.keepalive" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#911-916">Source</a><h4 class="code-header">pub fn <a href="#method.keepalive" class="fn">keepalive</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_KEEPALIVE</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_keepalive" title="method socket2::Socket::set_keepalive"><code>set_keepalive</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_keepalive" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#921-930">Source</a><h4 class="code-header">pub fn <a href="#method.set_keepalive" class="fn">set_keepalive</a>(&self, keepalive: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_KEEPALIVE</code> option on this socket.</p>
|
||
<p>Enable sending of keep-alive messages on connection-oriented sockets.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.linger" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#937-942">Source</a><h4 class="code-header">pub fn <a href="#method.linger" class="fn">linger</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_LINGER</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_linger" title="method socket2::Socket::set_linger"><code>set_linger</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_linger" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#958-961">Source</a><h4 class="code-header">pub fn <a href="#method.set_linger" class="fn">set_linger</a>(&self, linger: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_LINGER</code> option on this socket.</p>
|
||
<p>If <code>linger</code> is not <code>None</code>, a close(2) or shutdown(2) will not return
|
||
until all queued messages for the socket have been successfully sent or
|
||
the linger timeout has been reached. Otherwise, the call returns
|
||
immediately and the closing is done in the background. When the socket
|
||
is closed as part of exit(2), it always lingers in the background.</p>
|
||
<h5 id="notes-8"><a class="doc-anchor" href="#notes-8">§</a>Notes</h5>
|
||
<p>On most OSs the duration only has a precision of seconds and will be
|
||
silently truncated.</p>
|
||
<p>On Apple platforms (e.g. macOS, iOS, etc) this uses <code>SO_LINGER_SEC</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.out_of_band_inline" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#969-974">Source</a><h4 class="code-header">pub fn <a href="#method.out_of_band_inline" class="fn">out_of_band_inline</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get value for the <code>SO_OOBINLINE</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_out_of_band_inline" title="method socket2::Socket::set_out_of_band_inline"><code>set_out_of_band_inline</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_out_of_band_inline" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#983-992">Source</a><h4 class="code-header">pub fn <a href="#method.set_out_of_band_inline" class="fn">set_out_of_band_inline</a>(&self, oob_inline: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_OOBINLINE</code> option on this socket.</p>
|
||
<p>If this option is enabled, out-of-band data is directly placed into the
|
||
receive data stream. Otherwise, out-of-band data is passed only when the
|
||
<code>MSG_OOB</code> flag is set during receiving. As per RFC6093, TCP sockets
|
||
using the Urgent mechanism are encouraged to set this flag.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.passcred" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1000-1005">Source</a><h4 class="code-header">pub fn <a href="#method.passcred" class="fn">passcred</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get value for the <code>SO_PASSCRED</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_passcred" title="method socket2::Socket::set_passcred"><code>set_passcred</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_passcred" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1012-1021">Source</a><h4 class="code-header">pub fn <a href="#method.set_passcred" class="fn">set_passcred</a>(&self, passcred: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_PASSCRED</code> option on this socket.</p>
|
||
<p>If this option is enabled, enables the receiving of the <code>SCM_CREDENTIALS</code>
|
||
control messages.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.priority" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1032-1037">Source</a><h4 class="code-header">pub fn <a href="#method.priority" class="fn">priority</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get value for the <code>SO_PRIORITY</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_priority" title="method socket2::Socket::set_priority"><code>set_priority</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_priority" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1047-1056">Source</a><h4 class="code-header">pub fn <a href="#method.set_priority" class="fn">set_priority</a>(&self, priority: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_PRIORITY</code> option on this socket.</p>
|
||
<p>Packets with a higher priority may be processed earlier depending on the selected device
|
||
queueing discipline.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1063-1068">Source</a><h4 class="code-header">pub fn <a href="#method.recv_buffer_size" class="fn">recv_buffer_size</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Get value for the <code>SO_RCVBUF</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_recv_buffer_size" title="method socket2::Socket::set_recv_buffer_size"><code>set_recv_buffer_size</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_recv_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1074-1083">Source</a><h4 class="code-header">pub fn <a href="#method.set_recv_buffer_size" class="fn">set_recv_buffer_size</a>(&self, size: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_RCVBUF</code> option on this socket.</p>
|
||
<p>Changes the size of the operating system’s receive buffer associated
|
||
with the socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.read_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1089-1091">Source</a><h4 class="code-header">pub fn <a href="#method.read_timeout" class="fn">read_timeout</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></h4></section></summary><div class="docblock"><p>Get value for the <code>SO_RCVTIMEO</code> option on this socket.</p>
|
||
<p>If the returned timeout is <code>None</code>, then <code>read</code> and <code>recv</code> calls will
|
||
block indefinitely.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_read_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1097-1099">Source</a><h4 class="code-header">pub fn <a href="#method.set_read_timeout" class="fn">set_read_timeout</a>(&self, duration: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_RCVTIMEO</code> option on this socket.</p>
|
||
<p>If <code>timeout</code> is <code>None</code>, then <code>read</code> and <code>recv</code> calls will block
|
||
indefinitely.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.reuse_address" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1106-1111">Source</a><h4 class="code-header">pub fn <a href="#method.reuse_address" class="fn">reuse_address</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_REUSEADDR</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_reuse_address" title="method socket2::Socket::set_reuse_address"><code>set_reuse_address</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_reuse_address" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1118-1127">Source</a><h4 class="code-header">pub fn <a href="#method.set_reuse_address" class="fn">set_reuse_address</a>(&self, reuse: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_REUSEADDR</code> option on this socket.</p>
|
||
<p>This indicates that further calls to <code>bind</code> may allow reuse of local
|
||
addresses. For IPv4 sockets this means that a socket may bind even when
|
||
there’s a socket already listening on this port.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.send_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1134-1139">Source</a><h4 class="code-header">pub fn <a href="#method.send_buffer_size" class="fn">send_buffer_size</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_SNDBUF</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_send_buffer_size" title="method socket2::Socket::set_send_buffer_size"><code>set_send_buffer_size</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_send_buffer_size" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1145-1154">Source</a><h4 class="code-header">pub fn <a href="#method.set_send_buffer_size" class="fn">set_send_buffer_size</a>(&self, size: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_SNDBUF</code> option on this socket.</p>
|
||
<p>Changes the size of the operating system’s send buffer associated with
|
||
the socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1160-1162">Source</a><h4 class="code-header">pub fn <a href="#method.write_timeout" class="fn">write_timeout</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></h4></section></summary><div class="docblock"><p>Get value for the <code>SO_SNDTIMEO</code> option on this socket.</p>
|
||
<p>If the returned timeout is <code>None</code>, then <code>write</code> and <code>send</code> calls will
|
||
block indefinitely.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_write_timeout" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1168-1170">Source</a><h4 class="code-header">pub fn <a href="#method.set_write_timeout" class="fn">set_write_timeout</a>(&self, duration: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_SNDTIMEO</code> option on this socket.</p>
|
||
<p>If <code>timeout</code> is <code>None</code>, then <code>write</code> and <code>send</code> calls will block
|
||
indefinitely.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-2" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#1199-1711">Source</a><a href="#impl-Socket-2" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3><div class="docblock"><p>Socket options for IPv4 sockets, get/set using <code>IPPROTO_IP</code> or <code>SOL_IP</code>.</p>
|
||
</div></section></summary><div class="docblock"><p>Additional documentation can be found in documentation of the OS.</p>
|
||
<ul>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/ip.7.html">https://man7.org/linux/man-pages/man7/ip.7.html</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options</a></li>
|
||
</ul>
|
||
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.header_included_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1206-1211">Source</a><h4 class="code-header">pub fn <a href="#method.header_included_v4" class="fn">header_included_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_HDRINCL</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_header_included_v4" title="method socket2::Socket::set_header_included_v4"><code>set_header_included_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_header_included_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1229-1238">Source</a><h4 class="code-header">pub fn <a href="#method.set_header_included_v4" class="fn">set_header_included_v4</a>(&self, included: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_HDRINCL</code> option on this socket.</p>
|
||
<p>If enabled, the user supplies an IP header in front of the user data.
|
||
Valid only for <a href="struct.Type.html#associatedconstant.RAW" title="associated constant socket2::Type::RAW"><code>SOCK_RAW</code></a> sockets; see <a href="https://man7.org/linux/man-pages/man7/raw.7.html">raw(7)</a> for more information.
|
||
When this flag is enabled, the values set by <code>IP_OPTIONS</code>, <a href="struct.Socket.html#method.set_ttl_v4" title="method socket2::Socket::set_ttl_v4"><code>IP_TTL</code></a>,
|
||
and <a href="struct.Socket.html#method.set_tos_v4" title="method socket2::Socket::set_tos_v4"><code>IP_TOS</code></a> are ignored.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.ip_transparent_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1246-1251">Source</a><h4 class="code-header">pub fn <a href="#method.ip_transparent_v4" class="fn">ip_transparent_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_TRANSPARENT</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_ip_transparent_v4" title="method socket2::Socket::set_ip_transparent_v4"><code>set_ip_transparent_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_ip_transparent_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1269-1278">Source</a><h4 class="code-header">pub fn <a href="#method.set_ip_transparent_v4" class="fn">set_ip_transparent_v4</a>(&self, transparent: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_TRANSPARENT</code> option on this socket.</p>
|
||
<p>Setting this boolean option enables transparent proxying
|
||
on this socket. This socket option allows the calling
|
||
application to bind to a nonlocal IP address and operate
|
||
both as a client and a server with the foreign address as
|
||
the local endpoint. NOTE: this requires that routing be
|
||
set up in a way that packets going to the foreign address
|
||
are routed through the TProxy box (i.e., the system
|
||
hosting the application that employs the IP_TRANSPARENT
|
||
socket option). Enabling this socket option requires
|
||
superuser privileges (the <code>CAP_NET_ADMIN</code> capability).</p>
|
||
<p>TProxy redirection with the iptables TPROXY target also
|
||
requires that this option be set on the redirected socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.join_multicast_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1287-1293">Source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v4" class="fn">join_multicast_v4</a>(
|
||
&self,
|
||
multiaddr: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
interface: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Join a multicast group using <code>IP_ADD_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>This function specifies a new multicast group for this socket to join.
|
||
The address must be a valid multicast address, and <code>interface</code> is the
|
||
address of the local interface with which the system should join the
|
||
multicast group. If it’s <a href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED" title="associated constant core::net::ip_addr::Ipv4Addr::UNSPECIFIED"><code>Ipv4Addr::UNSPECIFIED</code></a> (<code>INADDR_ANY</code>) then
|
||
an appropriate interface is chosen by the system.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_multicast_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1300-1313">Source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v4" class="fn">leave_multicast_v4</a>(
|
||
&self,
|
||
multiaddr: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
interface: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IP_DROP_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.join_multicast_v4" title="method socket2::Socket::join_multicast_v4"><code>join_multicast_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.join_multicast_v4_n" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1334-1348">Source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v4_n" class="fn">join_multicast_v4_n</a>(
|
||
&self,
|
||
multiaddr: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
interface: &<a class="enum" href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress">InterfaceIndexOrAddress</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Join a multicast group using <code>IP_ADD_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>This function specifies a new multicast group for this socket to join.
|
||
The address must be a valid multicast address, and <code>interface</code> specifies
|
||
the local interface with which the system should join the multicast
|
||
group. See <a href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress"><code>InterfaceIndexOrAddress</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_multicast_v4_n" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1368-1382">Source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v4_n" class="fn">leave_multicast_v4_n</a>(
|
||
&self,
|
||
multiaddr: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
interface: &<a class="enum" href="enum.InterfaceIndexOrAddress.html" title="enum socket2::InterfaceIndexOrAddress">InterfaceIndexOrAddress</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IP_DROP_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.join_multicast_v4_n" title="method socket2::Socket::join_multicast_v4_n"><code>join_multicast_v4_n</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.join_ssm_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1403-1422">Source</a><h4 class="code-header">pub fn <a href="#method.join_ssm_v4" class="fn">join_ssm_v4</a>(
|
||
&self,
|
||
source: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
group: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
interface: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Join a multicast SSM channel using <code>IP_ADD_SOURCE_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>This function specifies a new multicast channel for this socket to join.
|
||
The group must be a valid SSM group address, the source must be the address of the sender
|
||
and <code>interface</code> is the address of the local interface with which the system should join the
|
||
multicast group. If it’s <a href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED" title="associated constant core::net::ip_addr::Ipv4Addr::UNSPECIFIED"><code>Ipv4Addr::UNSPECIFIED</code></a> (<code>INADDR_ANY</code>) then
|
||
an appropriate interface is chosen by the system.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_ssm_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1441-1460">Source</a><h4 class="code-header">pub fn <a href="#method.leave_ssm_v4" class="fn">leave_ssm_v4</a>(
|
||
&self,
|
||
source: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
group: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
interface: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IP_DROP_SOURCE_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.join_ssm_v4" title="method socket2::Socket::join_ssm_v4"><code>join_ssm_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_all_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1468-1473">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_all_v4" class="fn">multicast_all_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_MULTICAST_ALL</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_all_v4" title="method socket2::Socket::set_multicast_all_v4"><code>set_multicast_all_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_all_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1486-1495">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_all_v4" class="fn">set_multicast_all_v4</a>(&self, all: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_MULTICAST_ALL</code> option for this socket.</p>
|
||
<p>This option can be used to modify the delivery policy of
|
||
multicast messages. The argument is a boolean
|
||
(defaults to true). If set to true, the socket will receive
|
||
messages from all the groups that have been joined
|
||
globally on the whole system. Otherwise, it will deliver
|
||
messages only from the groups that have been explicitly
|
||
joined (for example via the <code>IP_ADD_MEMBERSHIP</code> option) on
|
||
this particular socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_if_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1502-1506">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_if_v4" class="fn">multicast_if_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_MULTICAST_IF</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_if_v4" title="method socket2::Socket::set_multicast_if_v4"><code>set_multicast_if_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_if_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1511-1521">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_if_v4" class="fn">set_multicast_if_v4</a>(&self, interface: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv4Addr.html" title="struct core::net::ip_addr::Ipv4Addr">Ipv4Addr</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_MULTICAST_IF</code> option for this socket.</p>
|
||
<p>Specifies the interface to use for routing multicast packets.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_loop_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1528-1533">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_loop_v4" class="fn">multicast_loop_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_MULTICAST_LOOP</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_loop_v4" title="method socket2::Socket::set_multicast_loop_v4"><code>set_multicast_loop_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_loop_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1539-1548">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_loop_v4" class="fn">set_multicast_loop_v4</a>(&self, loop_v4: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_MULTICAST_LOOP</code> option for this socket.</p>
|
||
<p>If enabled, multicast packets will be looped back to the local socket.
|
||
Note that this may not have any affect on IPv6 sockets.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_ttl_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1555-1560">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_ttl_v4" class="fn">multicast_ttl_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_MULTICAST_TTL</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_ttl_v4" title="method socket2::Socket::set_multicast_ttl_v4"><code>set_multicast_ttl_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_ttl_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1569-1578">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_ttl_v4" class="fn">set_multicast_ttl_v4</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_MULTICAST_TTL</code> option for this socket.</p>
|
||
<p>Indicates the time-to-live value of outgoing multicast packets for
|
||
this socket. The default value is 1 which means that multicast packets
|
||
don’t leave the local network unless explicitly requested.</p>
|
||
<p>Note that this may not have any affect on IPv6 sockets.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.ttl_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1585-1589">Source</a><h4 class="code-header">pub fn <a href="#method.ttl_v4" class="fn">ttl_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_TTL</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_ttl_v4" title="method socket2::Socket::set_ttl_v4"><code>set_ttl_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_ttl_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1595-1597">Source</a><h4 class="code-header">pub fn <a href="#method.set_ttl_v4" class="fn">set_ttl_v4</a>(&self, ttl: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_TTL</code> option for this socket.</p>
|
||
<p>This value sets the time-to-live field that is used in every packet sent
|
||
from this socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tos_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1613-1615">Source</a><h4 class="code-header">pub fn <a href="#method.set_tos_v4" class="fn">set_tos_v4</a>(&self, tos: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_TOS</code> option for this socket.</p>
|
||
<p>This value sets the type-of-service field that is used in every packet
|
||
sent from this socket.</p>
|
||
<p>NOTE: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options</a>
|
||
documents that not all versions of windows support <code>IP_TOS</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tos_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1632-1636">Source</a><h4 class="code-header">pub fn <a href="#method.tos_v4" class="fn">tos_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_TOS</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tos_v4" title="method socket2::Socket::set_tos_v4"><code>set_tos_v4</code></a>.</p>
|
||
<p>NOTE: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options</a>
|
||
documents that not all versions of windows support <code>IP_TOS</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_recv_tos_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1659-1668">Source</a><h4 class="code-header">pub fn <a href="#method.set_recv_tos_v4" class="fn">set_recv_tos_v4</a>(&self, recv_tos: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_RECVTOS</code> option for this socket.</p>
|
||
<p>If enabled, the <code>IP_TOS</code> ancillary message is passed with
|
||
incoming packets. It contains a byte which specifies the
|
||
Type of Service/Precedence field of the packet header.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_tos_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1691-1696">Source</a><h4 class="code-header">pub fn <a href="#method.recv_tos_v4" class="fn">recv_tos_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_RECVTOS</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_recv_tos_v4" title="method socket2::Socket::set_recv_tos_v4"><code>set_recv_tos_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.original_dst_v4" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1708-1710">Source</a><h4 class="code-header">pub fn <a href="#method.original_dst_v4" class="fn">original_dst_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>></h4></section></summary><div class="docblock"><p>Get the value for the <code>SO_ORIGINAL_DST</code> option on this socket.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-3" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#1718-2125">Source</a><a href="#impl-Socket-3" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3><div class="docblock"><p>Socket options for IPv6 sockets, get/set using <code>IPPROTO_IPV6</code> or <code>SOL_IPV6</code>.</p>
|
||
</div></section></summary><div class="docblock"><p>Additional documentation can be found in documentation of the OS.</p>
|
||
<ul>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/ipv6.7.html">https://man7.org/linux/man-pages/man7/ipv6.7.html</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options</a></li>
|
||
</ul>
|
||
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.header_included_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1735-1740">Source</a><h4 class="code-header">pub fn <a href="#method.header_included_v6" class="fn">header_included_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_HDRINCL</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_header_included_v6" title="method socket2::Socket::set_header_included_v6"><code>set_header_included_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_header_included_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1765-1777">Source</a><h4 class="code-header">pub fn <a href="#method.set_header_included_v6" class="fn">set_header_included_v6</a>(&self, included: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IP_HDRINCL</code> option on this socket.</p>
|
||
<p>If enabled, the user supplies an IP header in front of the user data.
|
||
Valid only for <a href="struct.Type.html#associatedconstant.RAW" title="associated constant socket2::Type::RAW"><code>SOCK_RAW</code></a> sockets; see <a href="https://man7.org/linux/man-pages/man7/raw.7.html">raw(7)</a> for more information.
|
||
When this flag is enabled, the values set by <code>IP_OPTIONS</code> are ignored.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.join_multicast_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1787-1801">Source</a><h4 class="code-header">pub fn <a href="#method.join_multicast_v6" class="fn">join_multicast_v6</a>(
|
||
&self,
|
||
multiaddr: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv6Addr.html" title="struct core::net::ip_addr::Ipv6Addr">Ipv6Addr</a>,
|
||
interface: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Join a multicast group using <code>IPV6_ADD_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>Some OSs use <code>IPV6_JOIN_GROUP</code> for this option.</p>
|
||
<p>This function specifies a new multicast group for this socket to join.
|
||
The address must be a valid multicast address, and <code>interface</code> is the
|
||
index of the interface to join/leave (or 0 to indicate any interface).</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.leave_multicast_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1811-1825">Source</a><h4 class="code-header">pub fn <a href="#method.leave_multicast_v6" class="fn">leave_multicast_v6</a>(
|
||
&self,
|
||
multiaddr: &<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/net/ip_addr/struct.Ipv6Addr.html" title="struct core::net::ip_addr::Ipv6Addr">Ipv6Addr</a>,
|
||
interface: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Leave a multicast group using <code>IPV6_DROP_MEMBERSHIP</code> option on this socket.</p>
|
||
<p>Some OSs use <code>IPV6_LEAVE_GROUP</code> for this option.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.join_multicast_v6" title="method socket2::Socket::join_multicast_v6"><code>join_multicast_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1832-1837">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_hops_v6" class="fn">multicast_hops_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_MULTICAST_HOPS</code> option for this socket</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_hops_v6" title="method socket2::Socket::set_multicast_hops_v6"><code>set_multicast_hops_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1844-1853">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_hops_v6" class="fn">set_multicast_hops_v6</a>(&self, hops: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_MULTICAST_HOPS</code> option for this socket</p>
|
||
<p>Indicates the number of “routers” multicast packets will transit for
|
||
this socket. The default value is 1 which means that multicast packets
|
||
don’t leave the local network unless explicitly requested.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_all_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1861-1866">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_all_v6" class="fn">multicast_all_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_MULTICAST_ALL</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_all_v6" title="method socket2::Socket::set_multicast_all_v6"><code>set_multicast_all_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_all_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1879-1888">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_all_v6" class="fn">set_multicast_all_v6</a>(&self, all: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_MULTICAST_ALL</code> option for this socket.</p>
|
||
<p>This option can be used to modify the delivery policy of
|
||
multicast messages. The argument is a boolean
|
||
(defaults to true). If set to true, the socket will receive
|
||
messages from all the groups that have been joined
|
||
globally on the whole system. Otherwise, it will deliver
|
||
messages only from the groups that have been explicitly
|
||
joined (for example via the <code>IPV6_ADD_MEMBERSHIP</code> option) on
|
||
this particular socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_if_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1895-1900">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_if_v6" class="fn">multicast_if_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_MULTICAST_IF</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_if_v6" title="method socket2::Socket::set_multicast_if_v6"><code>set_multicast_if_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_if_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1907-1916">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_if_v6" class="fn">set_multicast_if_v6</a>(&self, interface: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_MULTICAST_IF</code> option for this socket.</p>
|
||
<p>Specifies the interface to use for routing multicast packets. Unlike
|
||
ipv4, this is generally required in ipv6 contexts where network routing
|
||
prefixes may overlap.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.multicast_loop_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1923-1928">Source</a><h4 class="code-header">pub fn <a href="#method.multicast_loop_v6" class="fn">multicast_loop_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_MULTICAST_LOOP</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_multicast_loop_v6" title="method socket2::Socket::set_multicast_loop_v6"><code>set_multicast_loop_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_multicast_loop_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1934-1943">Source</a><h4 class="code-header">pub fn <a href="#method.set_multicast_loop_v6" class="fn">set_multicast_loop_v6</a>(&self, loop_v6: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_MULTICAST_LOOP</code> option for this socket.</p>
|
||
<p>Controls whether this socket sees the multicast packets it sends itself.
|
||
Note that this may not have any affect on IPv4 sockets.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.unicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1948-1953">Source</a><h4 class="code-header">pub fn <a href="#method.unicast_hops_v6" class="fn">unicast_hops_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_UNICAST_HOPS</code> option for this socket.</p>
|
||
<p>Specifies the hop limit for ipv6 unicast packets</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_unicast_hops_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1958-1967">Source</a><h4 class="code-header">pub fn <a href="#method.set_unicast_hops_v6" class="fn">set_unicast_hops_v6</a>(&self, hops: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value for the <code>IPV6_UNICAST_HOPS</code> option on this socket.</p>
|
||
<p>Specifies the hop limit for ipv6 unicast packets</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.only_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1974-1979">Source</a><h4 class="code-header">pub fn <a href="#method.only_v6" class="fn">only_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_V6ONLY</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_only_v6" title="method socket2::Socket::set_only_v6"><code>set_only_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_only_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#1989-1998">Source</a><h4 class="code-header">pub fn <a href="#method.set_only_v6" class="fn">set_only_v6</a>(&self, only_v6: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value for the <code>IPV6_V6ONLY</code> option on this socket.</p>
|
||
<p>If this is set to <code>true</code> then the socket is restricted to sending and
|
||
receiving IPv6 packets only. In this case two IPv4 and IPv6 applications
|
||
can bind the same port at the same time.</p>
|
||
<p>If this is set to <code>false</code> then the socket can be used to send and
|
||
receive packets from an IPv4-mapped IPv6 address.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_tclass_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2018-2023">Source</a><h4 class="code-header">pub fn <a href="#method.recv_tclass_v6" class="fn">recv_tclass_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_RECVTCLASS</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_recv_tclass_v6" title="method socket2::Socket::set_recv_tclass_v6"><code>set_recv_tclass_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_recv_tclass_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2043-2052">Source</a><h4 class="code-header">pub fn <a href="#method.set_recv_tclass_v6" class="fn">set_recv_tclass_v6</a>(&self, recv_tclass: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_RECVTCLASS</code> option for this socket.</p>
|
||
<p>If enabled, the <code>IPV6_TCLASS</code> ancillary message is passed with incoming
|
||
packets. It contains a byte which specifies the traffic class field of
|
||
the packet header.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.recv_hoplimit_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2077-2082">Source</a><h4 class="code-header">pub fn <a href="#method.recv_hoplimit_v6" class="fn">recv_hoplimit_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_RECVHOPLIMIT</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_recv_hoplimit_v6" title="method socket2::Socket::set_recv_hoplimit_v6"><code>set_recv_hoplimit_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_recv_hoplimit_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2106-2115">Source</a><h4 class="code-header">pub fn <a href="#method.set_recv_hoplimit_v6" class="fn">set_recv_hoplimit_v6</a>(&self, recv_hoplimit: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_RECVHOPLIMIT</code> option for this socket.</p>
|
||
<p>The received hop limit is returned as ancillary data by recvmsg()
|
||
only if the application has enabled the IPV6_RECVHOPLIMIT socket
|
||
option:</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.original_dst_v6" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2122-2124">Source</a><h4 class="code-header">pub fn <a href="#method.original_dst_v6" class="fn">original_dst_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>></h4></section></summary><div class="docblock"><p>Get the value for the <code>IP6T_SO_ORIGINAL_DST</code> option on this socket.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-4" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2132-2283">Source</a><a href="#impl-Socket-4" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3><div class="docblock"><p>Socket options for TCP sockets, get/set using <code>IPPROTO_TCP</code>.</p>
|
||
</div></section></summary><div class="docblock"><p>Additional documentation can be found in documentation of the OS.</p>
|
||
<ul>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man7/tcp.7.html">https://man7.org/linux/man-pages/man7/tcp.7.html</a></li>
|
||
<li>Windows: <a href="https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options">https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options</a></li>
|
||
</ul>
|
||
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.tcp_keepalive_time" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2146-2148">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_keepalive_time" class="fn">tcp_keepalive_time</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_KEEPIDLE</code> option on this socket.</p>
|
||
<p>This returns the value of <code>TCP_KEEPALIVE</code> on macOS and iOS and <code>TCP_KEEPIDLE</code> on all other
|
||
supported Unix operating systems.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_keepalive_interval" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2173-2178">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_keepalive_interval" class="fn">tcp_keepalive_interval</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_KEEPINTVL</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_keepalive" title="method socket2::Socket::set_tcp_keepalive"><code>set_tcp_keepalive</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_keepalive_retries" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2204-2209">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_keepalive_retries" class="fn">tcp_keepalive_retries</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_KEEPCNT</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_keepalive" title="method socket2::Socket::set_tcp_keepalive"><code>set_tcp_keepalive</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_keepalive" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2249-2252">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_keepalive" class="fn">set_tcp_keepalive</a>(&self, params: &<a class="struct" href="struct.TcpKeepalive.html" title="struct socket2::TcpKeepalive">TcpKeepalive</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set parameters configuring TCP keepalive probes for this socket.</p>
|
||
<p>The supported parameters depend on the operating system, and are
|
||
configured using the <a href="struct.TcpKeepalive.html" title="struct socket2::TcpKeepalive"><code>TcpKeepalive</code></a> struct. At a minimum, all systems
|
||
support configuring the <a href="struct.TcpKeepalive.html#method.with_time" title="method socket2::TcpKeepalive::with_time">keepalive time</a>: the time after which the OS
|
||
will start sending keepalive messages on an idle connection.</p>
|
||
<h5 id="notes-9"><a class="doc-anchor" href="#notes-9">§</a>Notes</h5>
|
||
<ul>
|
||
<li>This will enable <code>SO_KEEPALIVE</code> on this socket, if it is not already
|
||
enabled.</li>
|
||
<li>On some platforms, such as Windows, any keepalive parameters <em>not</em>
|
||
configured by the <code>TcpKeepalive</code> struct passed to this function may be
|
||
overwritten with their default values. Therefore, this function should
|
||
either only be called once per socket, or the same parameters should
|
||
be passed every time it is called.</li>
|
||
</ul>
|
||
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::time::Duration;
|
||
|
||
<span class="kw">use </span>socket2::{Socket, TcpKeepalive, Domain, Type};
|
||
|
||
<span class="kw">let </span>socket = Socket::new(Domain::IPV4, Type::STREAM, <span class="prelude-val">None</span>)<span class="question-mark">?</span>;
|
||
<span class="kw">let </span>keepalive = TcpKeepalive::new()
|
||
.with_time(Duration::from_secs(<span class="number">4</span>));
|
||
<span class="comment">// Depending on the target operating system, we may also be able to
|
||
// configure the keepalive probe interval and/or the number of
|
||
// retries here as well.
|
||
|
||
</span>socket.set_tcp_keepalive(<span class="kw-2">&</span>keepalive)<span class="question-mark">?</span>;</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_nodelay" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2259-2264">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_nodelay" class="fn">tcp_nodelay</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_NODELAY</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_nodelay" title="method socket2::Socket::set_tcp_nodelay"><code>set_tcp_nodelay</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_nodelay" class="method"><a class="src rightside" href="../src/socket2/socket.rs.html#2273-2282">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_nodelay" class="fn">set_tcp_nodelay</a>(&self, nodelay: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_NODELAY</code> option on this socket.</p>
|
||
<p>If set, this option disables the Nagle algorithm. This means that
|
||
segments are always sent as soon as possible, even if there is only a
|
||
small amount of data. When not set, data is buffered until there is a
|
||
sufficient amount to send out, thereby avoiding the frequent sending of
|
||
small packets.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Socket-5" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1416-2868">Source</a><a href="#impl-Socket-5" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3><div class="docblock"><p>Unix only API.</p>
|
||
</div></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.accept4" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1439-1441">Source</a><h4 class="code-header">pub fn <a href="#method.accept4" class="fn">accept4</a>(&self, flags: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><(<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>, <a class="struct" href="struct.SockAddr.html" title="struct socket2::SockAddr">SockAddr</a>)></h4></section></summary><div class="docblock"><p>Accept a new incoming connection from this listener.</p>
|
||
<p>This function directly corresponds to the <code>accept4(2)</code> function.</p>
|
||
<p>This function will block the calling thread until a new connection is
|
||
established. When established, the corresponding <code>Socket</code> and the remote
|
||
peer’s address will be returned.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=accept4&section=2">https://man.dragonflybsd.org/?command=accept4&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=accept4&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=accept4&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/accept4.2.html">https://man7.org/linux/man-pages/man2/accept4.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept4.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept4.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/accept4.2">https://man.netbsd.org/accept4.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/accept4.2">https://man.openbsd.org/accept4.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept4.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/accept4.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/accept4">https://illumos.org/man/3SOCKET/accept4</a></li>
|
||
</ul>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_cloexec" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1480-1482">Source</a><h4 class="code-header">pub fn <a href="#method.set_cloexec" class="fn">set_cloexec</a>(&self, close_on_exec: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Sets <code>CLOEXEC</code> on the socket.</p>
|
||
<h5 id="notes-10"><a class="doc-anchor" href="#notes-10">§</a>Notes</h5>
|
||
<p>On supported platforms you can use <a href="struct.Type.html#method.cloexec" title="method socket2::Type::cloexec"><code>Type::cloexec</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_mss" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1567-1572">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_mss" class="fn">tcp_mss</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Gets the value of the <code>TCP_MAXSEG</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_mss" title="method socket2::Socket::set_tcp_mss"><code>set_tcp_mss</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_mss" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1579-1588">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_mss" class="fn">set_tcp_mss</a>(&self, mss: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Sets the value of the <code>TCP_MAXSEG</code> option on this socket.</p>
|
||
<p>The <code>TCP_MAXSEG</code> option denotes the TCP Maximum Segment Size and is only
|
||
available on TCP sockets.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_listener" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1603-1608">Source</a><h4 class="code-header">pub fn <a href="#method.is_listener" class="fn">is_listener</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if <code>listen(2)</code> was called on this socket by checking the
|
||
<code>SO_ACCEPTCONN</code> option on this socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.domain" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1622-1624">Source</a><h4 class="code-header">pub fn <a href="#method.domain" class="fn">domain</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.Domain.html" title="struct socket2::Domain">Domain</a>></h4></section></summary><div class="docblock"><p>Returns the <a href="struct.Domain.html" title="struct socket2::Domain"><code>Domain</code></a> of this socket by checking the <code>SO_DOMAIN</code> option
|
||
on this socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.protocol" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1637-1645">Source</a><h4 class="code-header">pub fn <a href="#method.protocol" class="fn">protocol</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.Protocol.html" title="struct socket2::Protocol">Protocol</a>>></h4></section></summary><div class="docblock"><p>Returns the <a href="struct.Protocol.html" title="struct socket2::Protocol"><code>Protocol</code></a> of this socket by checking the <code>SO_PROTOCOL</code>
|
||
option on this socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.mark" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1657-1662">Source</a><h4 class="code-header">pub fn <a href="#method.mark" class="fn">mark</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Gets the value for the <code>SO_MARK</code> option on this socket.</p>
|
||
<p>This value gets the socket mark field for each packet sent through
|
||
this socket.</p>
|
||
<p>On Linux this function requires the <code>CAP_NET_ADMIN</code> capability.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_mark" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1675-1684">Source</a><h4 class="code-header">pub fn <a href="#method.set_mark" class="fn">set_mark</a>(&self, mark: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Sets the value for the <code>SO_MARK</code> option on this socket.</p>
|
||
<p>This value sets the socket mark field for each packet sent through
|
||
this socket. Changing the mark can be used for mark-based routing
|
||
without netfilter or for packet filtering.</p>
|
||
<p>On Linux this function requires the <code>CAP_NET_ADMIN</code> capability.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_cork" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1695-1700">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_cork" class="fn">tcp_cork</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_CORK</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_cork" title="method socket2::Socket::set_tcp_cork"><code>set_tcp_cork</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_cork" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1712-1721">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_cork" class="fn">set_tcp_cork</a>(&self, cork: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_CORK</code> option on this socket.</p>
|
||
<p>If set, don’t send out partial frames. All queued partial frames are
|
||
sent when the option is cleared again. There is a 200 millisecond ceiling on
|
||
the time for which output is corked by <code>TCP_CORK</code>. If this ceiling is reached,
|
||
then queued data is automatically transmitted.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_quickack" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1737-1742">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_quickack" class="fn">tcp_quickack</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_QUICKACK</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_quickack" title="method socket2::Socket::set_tcp_quickack"><code>set_tcp_quickack</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_quickack" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1759-1768">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_quickack" class="fn">set_tcp_quickack</a>(&self, quickack: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_QUICKACK</code> option on this socket.</p>
|
||
<p>If set, acks are sent immediately, rather than delayed if needed in accordance to normal
|
||
TCP operation. This flag is not permanent, it only enables a switch to or from quickack mode.
|
||
Subsequent operation of the TCP protocol will once again enter/leave quickack mode depending on
|
||
internal protocol processing and factors such as delayed ack timeouts occurring and data transfer.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_thin_linear_timeouts" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1779-1788">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_thin_linear_timeouts" class="fn">tcp_thin_linear_timeouts</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_THIN_LINEAR_TIMEOUTS</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_thin_linear_timeouts" title="method socket2::Socket::set_tcp_thin_linear_timeouts"><code>set_tcp_thin_linear_timeouts</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_thin_linear_timeouts" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1799-1808">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_thin_linear_timeouts" class="fn">set_tcp_thin_linear_timeouts</a>(&self, timeouts: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_THIN_LINEAR_TIMEOUTS</code> option on this socket.</p>
|
||
<p>If set, the kernel will dynamically detect a thin-stream connection if there are less than four packets in flight.
|
||
With less than four packets in flight the normal TCP fast retransmission will not be effective.
|
||
The kernel will modify the retransmission to avoid the very high latencies that thin stream suffer because of exponential backoff.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_notsent_lowat" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1816-1821">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_notsent_lowat" class="fn">tcp_notsent_lowat</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_NOTSENT_LOWAT</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_notsent_lowat" title="method socket2::Socket::set_tcp_notsent_lowat"><code>set_tcp_notsent_lowat</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_notsent_lowat" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1828-1837">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_notsent_lowat" class="fn">set_tcp_notsent_lowat</a>(&self, lowat: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_NOTSENT_LOWAT</code> option on this socket.</p>
|
||
<p>If set the kernel will limit the amount of <em>unsent</em> data in the sendbuffer.
|
||
This differs from <code>set_send_buffer_size</code> which limits the sum of unsent and unacknowledged data.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.device" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1846-1865">Source</a><h4 class="code-header">pub fn <a href="#method.device" class="fn">device</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>>>></h4></section></summary><div class="docblock"><p>Gets the value for the <code>SO_BINDTODEVICE</code> option on this socket.</p>
|
||
<p>This value gets the socket binded device’s interface name.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind_device" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1878-1892">Source</a><h4 class="code-header">pub fn <a href="#method.bind_device" class="fn">bind_device</a>(&self, interface: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Sets the value for the <code>SO_BINDTODEVICE</code> option on this socket.</p>
|
||
<p>If a socket is bound to an interface, only packets received from that
|
||
particular interface are processed by the socket. Note that this only
|
||
works for some socket types, particularly <code>AF_INET</code> sockets.</p>
|
||
<p>If <code>interface</code> is <code>None</code> or an empty string it removes the binding.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind_device_by_index_v4" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1933-1958">Source</a><h4 class="code-header">pub fn <a href="#method.bind_device_by_index_v4" class="fn">bind_device_by_index_v4</a>(
|
||
&self,
|
||
interface: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU32.html" title="type core::num::nonzero::NonZeroU32">NonZeroU32</a>>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Sets the value for <code>IP_BOUND_IF</code> or <code>SO_BINDTOIFINDEX</code> option on this socket.</p>
|
||
<p>If a socket is bound to an interface, only packets received from that
|
||
particular interface are processed by the socket.</p>
|
||
<p>If <code>interface</code> is <code>None</code>, the binding is removed. If the <code>interface</code>
|
||
index is not valid, an error is returned.</p>
|
||
<p>One can use <a href="../libc/unix/fn.if_nametoindex.html" title="fn libc::unix::if_nametoindex"><code>libc::if_nametoindex</code></a> to convert an interface alias to an
|
||
index.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.bind_device_by_index_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#1984-2009">Source</a><h4 class="code-header">pub fn <a href="#method.bind_device_by_index_v6" class="fn">bind_device_by_index_v6</a>(
|
||
&self,
|
||
interface: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU32.html" title="type core::num::nonzero::NonZeroU32">NonZeroU32</a>>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Sets the value for <code>IPV6_BOUND_IF</code> or <code>SO_BINDTOIFINDEX</code> option on this socket.</p>
|
||
<p>If a socket is bound to an interface, only packets received from that
|
||
particular interface are processed by the socket.</p>
|
||
<p>If <code>interface</code> is <code>None</code>, the binding is removed. If the <code>interface</code>
|
||
index is not valid, an error is returned.</p>
|
||
<p>One can use <a href="../libc/unix/fn.if_nametoindex.html" title="fn libc::unix::if_nametoindex"><code>libc::if_nametoindex</code></a> to convert an interface alias to an
|
||
index.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.device_index_v4" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2030-2049">Source</a><h4 class="code-header">pub fn <a href="#method.device_index_v4" class="fn">device_index_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU32.html" title="type core::num::nonzero::NonZeroU32">NonZeroU32</a>>></h4></section></summary><div class="docblock"><p>Gets the value for <code>IP_BOUND_IF</code> or <code>SO_BINDTOIFINDEX</code> option on this
|
||
socket, i.e. the index for the interface to which the socket is bound.</p>
|
||
<p>Returns <code>None</code> if the socket is not bound to any interface, otherwise
|
||
returns an interface index.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.device_index_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2070-2090">Source</a><h4 class="code-header">pub fn <a href="#method.device_index_v6" class="fn">device_index_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroU32.html" title="type core::num::nonzero::NonZeroU32">NonZeroU32</a>>></h4></section></summary><div class="docblock"><p>Gets the value for <code>IPV6_BOUND_IF</code> or <code>SO_BINDTOIFINDEX</code> option on this
|
||
socket, i.e. the index for the interface to which the socket is bound.</p>
|
||
<p>Returns <code>None</code> if the socket is not bound to any interface, otherwise
|
||
returns an interface index.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.cpu_affinity" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2098-2103">Source</a><h4 class="code-header">pub fn <a href="#method.cpu_affinity" class="fn">cpu_affinity</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_INCOMING_CPU</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_cpu_affinity" title="method socket2::Socket::set_cpu_affinity"><code>set_cpu_affinity</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_cpu_affinity" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2109-2118">Source</a><h4 class="code-header">pub fn <a href="#method.set_cpu_affinity" class="fn">set_cpu_affinity</a>(&self, cpu: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_INCOMING_CPU</code> option on this socket.</p>
|
||
<p>Sets the CPU affinity of the socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.reuse_port" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2129-2134">Source</a><h4 class="code-header">pub fn <a href="#method.reuse_port" class="fn">reuse_port</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>SO_REUSEPORT</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_reuse_port" title="method socket2::Socket::set_reuse_port"><code>set_reuse_port</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_reuse_port" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2145-2154">Source</a><h4 class="code-header">pub fn <a href="#method.set_reuse_port" class="fn">set_reuse_port</a>(&self, reuse: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>SO_REUSEPORT</code> option on this socket.</p>
|
||
<p>This indicates that further calls to <code>bind</code> may allow reuse of local
|
||
addresses. For IPv4 sockets this means that a socket may bind even when
|
||
there’s a socket already listening on this port.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.freebind_v4" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2194-2199">Source</a><h4 class="code-header">pub fn <a href="#method.freebind_v4" class="fn">freebind_v4</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IP_FREEBIND</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_freebind_v4" title="method socket2::Socket::set_freebind_v4"><code>set_freebind_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_freebind_v4" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2212-2221">Source</a><h4 class="code-header">pub fn <a href="#method.set_freebind_v4" class="fn">set_freebind_v4</a>(&self, freebind: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>IP_FREEBIND</code> option on this socket.</p>
|
||
<p>If enabled, this boolean option allows binding to an IP address that is
|
||
nonlocal or does not (yet) exist. This permits listening on a socket,
|
||
without requiring the underlying network interface or the specified
|
||
dynamic IP address to be up at the time that the application is trying
|
||
to bind to it.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.freebind_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2231-2236">Source</a><h4 class="code-header">pub fn <a href="#method.freebind_v6" class="fn">freebind_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_FREEBIND</code> option on this socket.</p>
|
||
<p>This is an IPv6 counterpart of <code>IP_FREEBIND</code> socket option on
|
||
Android/Linux. For more information about this option, see
|
||
<a href="struct.Socket.html#method.set_freebind_v4" title="method socket2::Socket::set_freebind_v4"><code>set_freebind_v4</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_freebind_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2269-2278">Source</a><h4 class="code-header">pub fn <a href="#method.set_freebind_v6" class="fn">set_freebind_v6</a>(&self, freebind: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>IPV6_FREEBIND</code> option on this socket.</p>
|
||
<p>This is an IPv6 counterpart of <code>IP_FREEBIND</code> socket option on
|
||
Android/Linux. For more information about this option, see
|
||
<a href="struct.Socket.html#method.set_freebind_v4" title="method socket2::Socket::set_freebind_v4"><code>set_freebind_v4</code></a>.</p>
|
||
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
||
<p>On Linux:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>socket2::{Domain, Socket, Type};
|
||
<span class="kw">use </span>std::io::{<span class="self">self</span>, Error, ErrorKind};
|
||
|
||
<span class="kw">fn </span>enable_freebind(socket: <span class="kw-2">&</span>Socket) -> io::Result<()> {
|
||
<span class="kw">match </span>socket.domain()<span class="question-mark">? </span>{
|
||
Domain::IPV4 => socket.set_freebind_v4(<span class="bool-val">true</span>)<span class="question-mark">?</span>,
|
||
Domain::IPV6 => socket.set_freebind_v6(<span class="bool-val">true</span>)<span class="question-mark">?</span>,
|
||
<span class="kw">_ </span>=> <span class="kw">return </span><span class="prelude-val">Err</span>(Error::new(ErrorKind::Other, <span class="string">"unsupported domain"</span>)),
|
||
};
|
||
<span class="prelude-val">Ok</span>(())
|
||
}
|
||
</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.sendfile" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2313-2323">Source</a><h4 class="code-header">pub fn <a href="#method.sendfile" class="fn">sendfile</a><F>(
|
||
&self,
|
||
file: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&F</a>,
|
||
offset: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>,
|
||
length: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.93.1/core/num/nonzero/type.NonZeroUsize.html" title="type core::num::nonzero::NonZeroUsize">NonZeroUsize</a>>,
|
||
) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>><div class="where">where
|
||
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.AsRawFd.html" title="trait std::os::fd::raw::AsRawFd">AsRawFd</a>,</div></h4></section></summary><div class="docblock"><p>Copies data between a <code>file</code> and this socket using the <code>sendfile(2)</code>
|
||
system call. Because this copying is done within the kernel,
|
||
<code>sendfile()</code> is more efficient than the combination of <code>read(2)</code> and
|
||
<code>write(2)</code>, which would require transferring data to and from user
|
||
space.</p>
|
||
<p>Different OSs support different kinds of <code>file</code>s, see the OS
|
||
documentation for what kind of files are supported. Generally <em>regular</em>
|
||
files are supported by all OSs.</p>
|
||
<p>Additional documentation can be found in manual of the OS:</p>
|
||
<ul>
|
||
<li>DragonFly BSD: <a href="https://man.dragonflybsd.org/?command=sendfile&section=2">https://man.dragonflybsd.org/?command=sendfile&section=2</a></li>
|
||
<li>FreeBSD: <a href="https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2">https://www.freebsd.org/cgi/man.cgi?query=sendfile&sektion=2</a></li>
|
||
<li>Linux: <a href="https://man7.org/linux/man-pages/man2/sendfile.2.html">https://man7.org/linux/man-pages/man2/sendfile.2.html</a></li>
|
||
<li>macOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html</a> (archived, actually for iOS)</li>
|
||
<li>NetBSD: <a href="https://man.netbsd.org/sendfile.2">https://man.netbsd.org/sendfile.2</a></li>
|
||
<li>OpenBSD: <a href="https://man.openbsd.org/sendfile.2">https://man.openbsd.org/sendfile.2</a></li>
|
||
<li>iOS: <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/sendfile.2.html</a> (archived)</li>
|
||
<li>illumos: <a href="https://illumos.org/man/3SOCKET/sendfile">https://illumos.org/man/3SOCKET/sendfile</a></li>
|
||
</ul>
|
||
<p>The <code>offset</code> is the absolute offset into the <code>file</code> to use as starting
|
||
point.</p>
|
||
<p>Depending on the OS this function <em>may</em> change the offset of <code>file</code>. For
|
||
the best results reset the offset of the file before using it again.</p>
|
||
<p>The <code>length</code> determines how many bytes to send, where a length of <code>None</code>
|
||
means it will try to send all bytes.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_user_timeout" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2450-2462">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_user_timeout" class="fn">set_tcp_user_timeout</a>(&self, timeout: <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_USER_TIMEOUT</code> option on this socket.</p>
|
||
<p>If set, this specifies the maximum amount of time that transmitted data may remain
|
||
unacknowledged or buffered data may remain untransmitted before TCP will forcibly close the
|
||
corresponding connection.</p>
|
||
<p>Setting <code>timeout</code> to <code>None</code> or a zero duration causes the system default timeouts to
|
||
be used. If <code>timeout</code> in milliseconds is larger than <code>c_uint::MAX</code>, the timeout is clamped
|
||
to <code>c_uint::MAX</code>. For example, when <code>c_uint</code> is a 32-bit value, this limits the timeout to
|
||
approximately 49.71 days.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_user_timeout" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2478-2489">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_user_timeout" class="fn">tcp_user_timeout</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_USER_TIMEOUT</code> option on this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_user_timeout" title="method socket2::Socket::set_tcp_user_timeout"><code>set_tcp_user_timeout</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.attach_filter" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2498-2513">Source</a><h4 class="code-header">pub fn <a href="#method.attach_filter" class="fn">attach_filter</a>(&self, filters: &[<a class="struct" href="struct.SockFilter.html" title="struct socket2::SockFilter">SockFilter</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Attach Berkeley Packet Filter (BPF) on this socket.</p>
|
||
<p>BPF allows a user-space program to attach a filter onto any socket
|
||
and allow or disallow certain types of data to come through the socket.</p>
|
||
<p>For more information about this option, see <a href="https://www.kernel.org/doc/html/v5.12/networking/filter.html">filter</a></p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.detach_filter" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2521-2523">Source</a><h4 class="code-header">pub fn <a href="#method.detach_filter" class="fn">detach_filter</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Detach Berkeley Packet Filter(BPF) from this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.attach_filter" title="method socket2::Socket::attach_filter"><code>attach_filter</code></a></p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.cookie" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2532-2534">Source</a><h4 class="code-header">pub fn <a href="#method.cookie" class="fn">cookie</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u64.html">u64</a>></h4></section></summary><div class="docblock"><p>Gets the value for the <code>SO_COOKIE</code> option on this socket.</p>
|
||
<p>The socket cookie is a unique, kernel-managed identifier tied to each socket.
|
||
Therefore, there is no corresponding <code>set</code> helper.</p>
|
||
<p>For more information about this option, see <a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5daab9db7b65df87da26fd8cfa695fb9546a1ddb">Linux patch</a></p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tclass_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2555-2560">Source</a><h4 class="code-header">pub fn <a href="#method.tclass_v6" class="fn">tclass_v6</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>IPV6_TCLASS</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tclass_v6" title="method socket2::Socket::set_tclass_v6"><code>set_tclass_v6</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tclass_v6" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2580-2589">Source</a><h4 class="code-header">pub fn <a href="#method.set_tclass_v6" class="fn">set_tclass_v6</a>(&self, tclass: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>IPV6_TCLASS</code> option for this socket.</p>
|
||
<p>Specifies the traffic class field that is used in every packets
|
||
sent from this socket.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.tcp_congestion" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2597-2608">Source</a><h4 class="code-header">pub fn <a href="#method.tcp_congestion" class="fn">tcp_congestion</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>>></h4></section></summary><div class="docblock"><p>Get the value of the <code>TCP_CONGESTION</code> option for this socket.</p>
|
||
<p>For more information about this option, see <a href="struct.Socket.html#method.set_tcp_congestion" title="method socket2::Socket::set_tcp_congestion"><code>set_tcp_congestion</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_tcp_congestion" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2617-2626">Source</a><h4 class="code-header">pub fn <a href="#method.set_tcp_congestion" class="fn">set_tcp_congestion</a>(&self, tcp_ca_name: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>TCP_CONGESTION</code> option for this socket.</p>
|
||
<p>Specifies the TCP congestion control algorithm to use for this socket.</p>
|
||
<p>The value must be a valid TCP congestion control algorithm name of the
|
||
platform. For example, Linux may supports “reno”, “cubic”.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_dccp_service" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2639-2648">Source</a><h4 class="code-header">pub fn <a href="#method.set_dccp_service" class="fn">set_dccp_service</a>(&self, code: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>DCCP_SOCKOPT_SERVICE</code> option on this socket.</p>
|
||
<p>Sets the DCCP service. The specification mandates use of service codes.
|
||
If this socket option is not set, the socket will fall back to 0 (which
|
||
means that no meaningful service code is present). On active sockets
|
||
this is set before <a href="struct.Socket.html#method.connect" title="method socket2::Socket::connect"><code>connect</code></a>. On passive sockets up to 32 service
|
||
codes can be set before calling <a href="struct.Socket.html#method.bind" title="method socket2::Socket::bind"><code>bind</code></a></p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_service" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2656-2658">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_service" class="fn">dccp_service</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_SERVICE</code> option on this socket.</p>
|
||
<p>For more information about this option see <a href="struct.Socket.html#method.set_dccp_service" title="method socket2::Socket::set_dccp_service"><code>set_dccp_service</code></a></p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_dccp_ccid" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2664-2666">Source</a><h4 class="code-header">pub fn <a href="#method.set_dccp_ccid" class="fn">set_dccp_ccid</a>(&self, ccid: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>DCCP_SOCKOPT_CCID</code> option on this socket.</p>
|
||
<p>This option sets both the TX and RX CCIDs at the same time.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_tx_ccid" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2674-2676">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_tx_ccid" class="fn">dccp_tx_ccid</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_TX_CCID</code> option on this socket.</p>
|
||
<p>For more information about this option see <a href="struct.Socket.html#method.set_dccp_ccid" title="method socket2::Socket::set_dccp_ccid"><code>set_dccp_ccid</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_xx_ccid" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2684-2686">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_xx_ccid" class="fn">dccp_xx_ccid</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_RX_CCID</code> option on this socket.</p>
|
||
<p>For more information about this option see <a href="struct.Socket.html#method.set_dccp_ccid" title="method socket2::Socket::set_dccp_ccid"><code>set_dccp_ccid</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_dccp_server_timewait" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2693-2702">Source</a><h4 class="code-header">pub fn <a href="#method.set_dccp_server_timewait" class="fn">set_dccp_server_timewait</a>(&self, hold_timewait: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>DCCP_SOCKOPT_SERVER_TIMEWAIT</code> option on this socket.</p>
|
||
<p>Enables a listening socket to hold timewait state when closing the
|
||
connection. This option must be set after <code>accept</code> returns.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_server_timewait" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2710-2718">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_server_timewait" class="fn">dccp_server_timewait</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_SERVER_TIMEWAIT</code> option on this socket.</p>
|
||
<p>For more information see <a href="struct.Socket.html#method.set_dccp_server_timewait" title="method socket2::Socket::set_dccp_server_timewait"><code>set_dccp_server_timewait</code></a></p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_dccp_send_cscov" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2728-2737">Source</a><h4 class="code-header">pub fn <a href="#method.set_dccp_send_cscov" class="fn">set_dccp_send_cscov</a>(&self, level: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>DCCP_SOCKOPT_SEND_CSCOV</code> option on this socket.</p>
|
||
<p>Both this option and <code>DCCP_SOCKOPT_RECV_CSCOV</code> are used for setting the
|
||
partial checksum coverage. The default is that checksums always cover
|
||
the entire packet and that only fully covered application data is
|
||
accepted by the receiver. Hence, when using this feature on the sender,
|
||
it must be enabled at the receiver too, with suitable choice of CsCov.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_send_cscov" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2745-2747">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_send_cscov" class="fn">dccp_send_cscov</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_SEND_CSCOV</code> option on this socket.</p>
|
||
<p>For more information on this option see <a href="struct.Socket.html#method.set_dccp_send_cscov" title="method socket2::Socket::set_dccp_send_cscov"><code>set_dccp_send_cscov</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_dccp_recv_cscov" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2755-2764">Source</a><h4 class="code-header">pub fn <a href="#method.set_dccp_recv_cscov" class="fn">set_dccp_recv_cscov</a>(&self, level: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value of the <code>DCCP_SOCKOPT_RECV_CSCOV</code> option on this socket.</p>
|
||
<p>This option is only useful when combined with <a href="struct.Socket.html#method.set_dccp_send_cscov" title="method socket2::Socket::set_dccp_send_cscov"><code>set_dccp_send_cscov</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_recv_cscov" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2772-2774">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_recv_cscov" class="fn">dccp_recv_cscov</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_RECV_CSCOV</code> option on this socket.</p>
|
||
<p>For more information on this option see <a href="struct.Socket.html#method.set_dccp_recv_cscov" title="method socket2::Socket::set_dccp_recv_cscov"><code>set_dccp_recv_cscov</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_dccp_qpolicy_txqlen" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2781-2790">Source</a><h4 class="code-header">pub fn <a href="#method.set_dccp_qpolicy_txqlen" class="fn">set_dccp_qpolicy_txqlen</a>(&self, length: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set value for the <code>DCCP_SOCKOPT_QPOLICY_TXQLEN</code> option on this socket.</p>
|
||
<p>This option sets the maximum length of the output queue. A zero value is
|
||
interpreted as unbounded queue length.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_qpolicy_txqlen" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2798-2806">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_qpolicy_txqlen" class="fn">dccp_qpolicy_txqlen</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_QPOLICY_TXQLEN</code> on this socket.</p>
|
||
<p>For more information on this option see <a href="struct.Socket.html#method.set_dccp_qpolicy_txqlen" title="method socket2::Socket::set_dccp_qpolicy_txqlen"><code>set_dccp_qpolicy_txqlen</code></a>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_available_ccids" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2818-2829">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_available_ccids" class="fn">dccp_available_ccids</a><const N: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.CcidEndpoints.html" title="struct socket2::CcidEndpoints">CcidEndpoints</a><N>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_AVAILABLE_CCIDS</code> option on this socket.</p>
|
||
<p>Returns the list of CCIDs supported by the endpoint.</p>
|
||
<p>The parameter <code>N</code> is used to get the maximum number of supported
|
||
endpoints. The <a href="https://www.kernel.org/doc/html/latest/networking/dccp.html">documentation</a> recommends a minimum of four at the time
|
||
of writing.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.dccp_cur_mps" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2836-2844">Source</a><h4 class="code-header">pub fn <a href="#method.dccp_cur_mps" class="fn">dccp_cur_mps</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value of the <code>DCCP_SOCKOPT_GET_CUR_MPS</code> option on this socket.</p>
|
||
<p>This option retrieves the current maximum packet size (application
|
||
payload size) in bytes.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.busy_poll" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2850-2852">Source</a><h4 class="code-header">pub fn <a href="#method.busy_poll" class="fn">busy_poll</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>Get the value for the <code>SO_BUSY_POLL</code> option on this socket.</p>
|
||
<p>On Linux this function requires the <code>CAP_NET_ADMIN</code> capability.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_busy_poll" class="method"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2858-2867">Source</a><h4 class="code-header">pub fn <a href="#method.set_busy_poll" class="fn">set_busy_poll</a>(&self, busy_poll: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Set the value for the <code>SO_BUSY_POLL</code> option on this socket.</p>
|
||
<p>On Linux this function requires the <code>CAP_NET_ADMIN</code> capability.</p>
|
||
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-AsFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2920-2925">Source</a><a href="#impl-AsFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/trait.AsFd.html" title="trait std::os::fd::owned::AsFd">AsFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2921-2924">Source</a><a href="#method.as_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/trait.AsFd.html#tymethod.as_fd" class="fn">as_fd</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/struct.BorrowedFd.html" title="struct std::os::fd::owned::BorrowedFd">BorrowedFd</a><'_></h4></section></summary><div class='docblock'>Borrows the file descriptor. <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/trait.AsFd.html#tymethod.as_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AsRawFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2927-2931">Source</a><a href="#impl-AsRawFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.AsRawFd.html" title="trait std::os::fd::raw::AsRawFd">AsRawFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_raw_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2928-2930">Source</a><a href="#method.as_raw_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd" class="fn">as_raw_fd</a>(&self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/type.RawFd.html" title="type std::os::fd::raw::RawFd">RawFd</a></h4></section></summary><div class='docblock'>Extracts the raw file descriptor. <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2349-2357">Source</a><a href="#impl-Debug-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2350-2356">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3COwnedFd%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2946-2951">Source</a><a href="#impl-From%3COwnedFd%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a>> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-7" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2947-2950">Source</a><a href="#method.from-7" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(fd: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-OwnedFd" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2933-2938">Source</a><a href="#impl-From%3CSocket%3E-for-OwnedFd" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-6" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2934-2937">Source</a><a href="#method.from-6" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(sock: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-TcpListener" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2363">Source</a><a href="#impl-From%3CSocket%3E-for-TcpListener" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-4" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2363">Source</a><a href="#method.from-4" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-TcpStream" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2362">Source</a><a href="#impl-From%3CSocket%3E-for-TcpStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-3" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2362">Source</a><a href="#method.from-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UdpSocket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2364">Source</a><a href="#impl-From%3CSocket%3E-for-UdpSocket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-5" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2364">Source</a><a href="#method.from-5" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixDatagram" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2970">Source</a><a href="#impl-From%3CSocket%3E-for-UnixDatagram" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-13" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2970">Source</a><a href="#method.from-13" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixListener" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2968">Source</a><a href="#impl-From%3CSocket%3E-for-UnixListener" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-12" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2968">Source</a><a href="#method.from-12" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CSocket%3E-for-UnixStream" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2966">Source</a><a href="#impl-From%3CSocket%3E-for-UnixStream" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-11" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2966">Source</a><a href="#method.from-11" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CTcpListener%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2360">Source</a><a href="#impl-From%3CTcpListener%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a>> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2360">Source</a><a href="#method.from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpListener.html" title="struct std::net::tcp::TcpListener">TcpListener</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CTcpStream%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2359">Source</a><a href="#impl-From%3CTcpStream%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2359">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/tcp/struct.TcpStream.html" title="struct std::net::tcp::TcpStream">TcpStream</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUdpSocket%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2361">Source</a><a href="#impl-From%3CUdpSocket%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a>> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-2" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2361">Source</a><a href="#method.from-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/net/udp/struct.UdpSocket.html" title="struct std::net::udp::UdpSocket">UdpSocket</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUnixDatagram%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2964">Source</a><a href="#impl-From%3CUnixDatagram%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a>> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-10" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2964">Source</a><a href="#method.from-10" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/datagram/struct.UnixDatagram.html" title="struct std::os::unix::net::datagram::UnixDatagram">UnixDatagram</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUnixListener%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2962">Source</a><a href="#impl-From%3CUnixListener%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a>> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-9" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2962">Source</a><a href="#method.from-9" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/listener/struct.UnixListener.html" title="struct std::os::unix::net::listener::UnixListener">UnixListener</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUnixStream%3E-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2960">Source</a><a href="#impl-From%3CUnixStream%3E-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a>> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-8" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2960">Source</a><a href="#method.from-8" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(socket: <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/os/unix/net/stream/struct.UnixStream.html" title="struct std::os::unix::net::stream::UnixStream">UnixStream</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-FromRawFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2953-2957">Source</a><a href="#impl-FromRawFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.FromRawFd.html" title="trait std::os::fd::raw::FromRawFd">FromRawFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from_raw_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2954-2956">Source</a><a href="#method.from_raw_fd" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.FromRawFd.html#tymethod.from_raw_fd" class="fn">from_raw_fd</a>(fd: <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a>) -> <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a> <a href="#" class="tooltip" data-notable-ty="Socket">ⓘ</a></h4></section></summary><div class='docblock'>Constructs a new instance of <code>Self</code> from the given raw file
|
||
descriptor. <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.FromRawFd.html#tymethod.from_raw_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-IntoRawFd-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2940-2944">Source</a><a href="#impl-IntoRawFd-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.IntoRawFd.html" title="trait std::os::fd::raw::IntoRawFd">IntoRawFd</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into_raw_fd" class="method trait-impl"><a class="src rightside" href="../src/socket2/sys/unix.rs.html#2941-2943">Source</a><a href="#method.into_raw_fd" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.IntoRawFd.html#tymethod.into_raw_fd" class="fn">into_raw_fd</a>(self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/core/ffi/primitives/type.c_int.html" title="type core::ffi::primitives::c_int">c_int</a></h4></section></summary><div class='docblock'>Consumes this object, returning the raw underlying file descriptor. <a href="https://doc.rust-lang.org/1.93.1/std/os/fd/raw/trait.IntoRawFd.html#tymethod.into_raw_fd">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Read-for-%26Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2304-2317">Source</a><a href="#impl-Read-for-%26Socket" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for &'a <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.read-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2305-2309">Source</a><a href="#method.read-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#tymethod.read" class="fn">read</a>(&mut self, buf: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Pull some bytes from this source into the specified buffer, returning
|
||
how many bytes were read. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#tymethod.read">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_vectored-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2312-2316">Source</a><a href="#method.read_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_vectored" class="fn">read_vectored</a>(&mut self, bufs: &mut [<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a><'_>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Like <code>read</code>, except that it reads into a slice of buffers. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_read_vectored-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#838">Source</a><a href="#method.is_read_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.is_read_vectored" class="fn">is_read_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Read</code>er has an efficient <code>read_vectored</code>
|
||
implementation. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.is_read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_end-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#935">Source</a></span><a href="#method.read_to_end-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_end" class="fn">read_to_end</a>(&mut self, buf: &mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Reads all bytes until EOF in this source, placing them into <code>buf</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_end">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_string-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#991">Source</a></span><a href="#method.read_to_string-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_string" class="fn">read_to_string</a>(&mut self, buf: &mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Reads all bytes until EOF in this source, appending them to <code>buf</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_string">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_exact-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.6.0">1.6.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1044">Source</a></span><a href="#method.read_exact-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_exact" class="fn">read_exact</a>(&mut self, buf: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Reads the exact number of bytes required to fill <code>buf</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1057">Source</a><a href="#method.read_buf-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf" class="fn">read_buf</a>(&mut self, buf: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Pull some bytes from this source into the specified buffer. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf_exact-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1080">Source</a><a href="#method.read_buf_exact-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf_exact" class="fn">read_buf_exact</a>(&mut self, cursor: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Reads the exact number of bytes required to fill <code>cursor</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1119-1121">Source</a></span><a href="#method.by_ref-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.by_ref" class="fn">by_ref</a>(&mut self) -> &mut Self<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adapter for this instance of <code>Read</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.by_ref">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.bytes-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1162-1164">Source</a></span><a href="#method.bytes-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.bytes" class="fn">bytes</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a><Self><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Transforms this <code>Read</code> instance to an <a href="https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> over its bytes. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.bytes">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.chain-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1200-1202">Source</a></span><a href="#method.chain-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.chain" class="fn">chain</a><R>(self, next: R) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a><Self, R><div class="where">where
|
||
R: <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will chain this stream with another. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.chain">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.take-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1239-1241">Source</a></span><a href="#method.take-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.take" class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u64.html">u64</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.Take.html" title="struct std::io::Take">Take</a><Self><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will read at most <code>limit</code> bytes from it. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.take">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_array-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1274-1276">Source</a><a href="#method.read_array-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_array" class="fn">read_array</a><const N: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.array.html">N</a>], <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_array</code>)</span></div></span><div class='docblock'>Read and return a fixed array of bytes from this source. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_array">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Read-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2285-2302">Source</a><a href="#impl-Read-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.read" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2286-2291">Source</a><a href="#method.read" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#tymethod.read" class="fn">read</a>(&mut self, buf: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Pull some bytes from this source into the specified buffer, returning
|
||
how many bytes were read. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#tymethod.read">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_vectored" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2294-2301">Source</a><a href="#method.read_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_vectored" class="fn">read_vectored</a>(&mut self, bufs: &mut [<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a><'_>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Like <code>read</code>, except that it reads into a slice of buffers. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_read_vectored" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#838">Source</a><a href="#method.is_read_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.is_read_vectored" class="fn">is_read_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Read</code>er has an efficient <code>read_vectored</code>
|
||
implementation. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.is_read_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_end" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#935">Source</a></span><a href="#method.read_to_end" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_end" class="fn">read_to_end</a>(&mut self, buf: &mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Reads all bytes until EOF in this source, placing them into <code>buf</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_end">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_to_string" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#991">Source</a></span><a href="#method.read_to_string" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_string" class="fn">read_to_string</a>(&mut self, buf: &mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Reads all bytes until EOF in this source, appending them to <code>buf</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_to_string">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_exact" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.6.0">1.6.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1044">Source</a></span><a href="#method.read_exact" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_exact" class="fn">read_exact</a>(&mut self, buf: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Reads the exact number of bytes required to fill <code>buf</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1057">Source</a><a href="#method.read_buf" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf" class="fn">read_buf</a>(&mut self, buf: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Pull some bytes from this source into the specified buffer. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_buf_exact" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1080">Source</a><a href="#method.read_buf_exact" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf_exact" class="fn">read_buf_exact</a>(&mut self, cursor: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/io/borrowed_buf/struct.BorrowedCursor.html" title="struct core::io::borrowed_buf::BorrowedCursor">BorrowedCursor</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_buf</code>)</span></div></span><div class='docblock'>Reads the exact number of bytes required to fill <code>cursor</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_buf_exact">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1119-1121">Source</a></span><a href="#method.by_ref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.by_ref" class="fn">by_ref</a>(&mut self) -> &mut Self<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adapter for this instance of <code>Read</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.by_ref">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.bytes" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1162-1164">Source</a></span><a href="#method.bytes" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.bytes" class="fn">bytes</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a><Self><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Transforms this <code>Read</code> instance to an <a href="https://doc.rust-lang.org/1.93.1/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> over its bytes. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.bytes">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.chain" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1200-1202">Source</a></span><a href="#method.chain" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.chain" class="fn">chain</a><R>(self, next: R) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a><Self, R><div class="where">where
|
||
R: <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will chain this stream with another. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.chain">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.take" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1239-1241">Source</a></span><a href="#method.take" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.take" class="fn">take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u64.html">u64</a>) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.Take.html" title="struct std::io::Take">Take</a><Self><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates an adapter which will read at most <code>limit</code> bytes from it. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.take">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.read_array" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1274-1276">Source</a><a href="#method.read_array" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_array" class="fn">read_array</a><const N: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.array.html">N</a>], <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>><div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>read_array</code>)</span></div></span><div class='docblock'>Read and return a fixed array of bytes from this source. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html#method.read_array">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Write-for-%26Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2334-2347">Source</a><a href="#impl-Write-for-%26Socket" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for &'a <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.write-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2335-2337">Source</a><a href="#method.write-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.write" class="fn">write</a>(&mut self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Writes a buffer into this writer, returning how many bytes were written. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.write">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_vectored-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2340-2342">Source</a><a href="#method.write_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_vectored" class="fn">write_vectored</a>(&mut self, bufs: &[<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Like <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.write" title="method std::io::Write::write"><code>write</code></a>, except that it writes from a slice of buffers. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.flush-1" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2344-2346">Source</a><a href="#method.flush-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.flush" class="fn">flush</a>(&mut self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class='docblock'>Flushes this output stream, ensuring that all intermediately buffered
|
||
contents reach their destination. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.flush">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_write_vectored-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1813">Source</a><a href="#method.is_write_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.is_write_vectored" class="fn">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Write</code>r has an efficient <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_vectored" title="method std::io::Write::write_vectored"><code>write_vectored</code></a>
|
||
implementation. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.is_write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1875">Source</a></span><a href="#method.write_all-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all" class="fn">write_all</a>(&mut self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Attempts to write an entire buffer into this writer. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all_vectored-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1937">Source</a><a href="#method.write_all_vectored-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all_vectored" class="fn">write_all_vectored</a>(&mut self, bufs: &mut [<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>]) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>write_all_vectored</code>)</span></div></span><div class='docblock'>Attempts to write multiple buffers into this writer. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_fmt-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1990">Source</a></span><a href="#method.write_fmt-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_fmt" class="fn">write_fmt</a>(&mut self, args: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/struct.Arguments.html" title="struct core::fmt::Arguments">Arguments</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Writes a formatted string into this writer, returning any error
|
||
encountered. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_fmt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref-3" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#2020-2022">Source</a></span><a href="#method.by_ref-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.by_ref" class="fn">by_ref</a>(&mut self) -> &mut Self<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adapter for this instance of <code>Write</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.by_ref">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Write-for-Socket" class="impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2319-2332">Source</a><a href="#impl-Write-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.write" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2320-2322">Source</a><a href="#method.write" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.write" class="fn">write</a>(&mut self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Writes a buffer into this writer, returning how many bytes were written. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.write">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_vectored" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2325-2327">Source</a><a href="#method.write_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_vectored" class="fn">write_vectored</a>(&mut self, bufs: &[<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>]) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>></h4></section></summary><div class='docblock'>Like <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.write" title="method std::io::Write::write"><code>write</code></a>, except that it writes from a slice of buffers. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.flush" class="method trait-impl"><a class="src rightside" href="../src/socket2/socket.rs.html#2329-2331">Source</a><a href="#method.flush" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.flush" class="fn">flush</a>(&mut self) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>></h4></section></summary><div class='docblock'>Flushes this output stream, ensuring that all intermediately buffered
|
||
contents reach their destination. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#tymethod.flush">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_write_vectored" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1813">Source</a><a href="#method.is_write_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.is_write_vectored" class="fn">is_write_vectored</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.bool.html">bool</a></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>can_vector</code>)</span></div></span><div class='docblock'>Determines if this <code>Write</code>r has an efficient <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_vectored" title="method std::io::Write::write_vectored"><code>write_vectored</code></a>
|
||
implementation. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.is_write_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1875">Source</a></span><a href="#method.write_all" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all" class="fn">write_all</a>(&mut self, buf: &[<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Attempts to write an entire buffer into this writer. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_all_vectored" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1937">Source</a><a href="#method.write_all_vectored" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all_vectored" class="fn">write_all_vectored</a>(&mut self, bufs: &mut [<a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/struct.IoSlice.html" title="struct std::io::IoSlice">IoSlice</a><'_>]) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>write_all_vectored</code>)</span></div></span><div class='docblock'>Attempts to write multiple buffers into this writer. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_all_vectored">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.write_fmt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#1990">Source</a></span><a href="#method.write_fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_fmt" class="fn">write_fmt</a>(&mut self, args: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/struct.Arguments.html" title="struct core::fmt::Arguments">Arguments</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class='docblock'>Writes a formatted string into this writer, returning any error
|
||
encountered. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.write_fmt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.by_ref-2" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.93.1/src/std/io/mod.rs.html#2020-2022">Source</a></span><a href="#method.by_ref-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.by_ref" class="fn">by_ref</a>(&mut self) -> &mut Self<div class="where">where
|
||
Self: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Creates a “by reference” adapter for this instance of <code>Write</code>. <a href="https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html#method.by_ref">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Socket" class="impl"><a href="#impl-Freeze-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-RefUnwindSafe-for-Socket" class="impl"><a href="#impl-RefUnwindSafe-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-Send-for-Socket" class="impl"><a href="#impl-Send-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-Sync-for-Socket" class="impl"><a href="#impl-Sync-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-Unpin-for-Socket" class="impl"><a href="#impl-Unpin-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section><section id="impl-UnwindSafe-for-Socket" class="impl"><a href="#impl-UnwindSafe-for-Socket" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Socket.html" title="struct socket2::Socket">Socket</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#785">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-14" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from-14" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#767-769">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||
<p>That is, this conversion is whatever the implementation of
|
||
<code><a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#827-829">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#811-813">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div><script type="text/json" id="notable-traits-data">{"Socket":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl<'a> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for &'a <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div><div class=\"where\">impl<'a> <a class=\"trait\" href=\"https://doc.rust-lang.org/1.93.1/std/io/trait.Write.html\" title=\"trait std::io::Write\">Write</a> for &'a <a class=\"struct\" href=\"struct.Socket.html\" title=\"struct socket2::Socket\">Socket</a></div>"}</script></section></div></main></body></html> |