NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #31 most downloaded on crates.io
Utilities for handling networking sockets with a maximal amount of configuration possible intended.
Last release 2 months ago
13 Jul 2026
Ships fairly regularly
a new release about every 3 months
Most releases are documented
notes for 26 of 35 stable releases
19 versions withdrawn
withdrawn after publishing
9 years old
59 releases · first in 2017
Add support for Emscripten (wasm32) (https://github.com/rust-lang/socket2/pull/660).
Socket::(set_)tos_v4 on illumos
(https://github.com/rust-lang/socket2/pull/662).Implement Send for MsgHdr(Mut) (https://github.com/rust-lang/socket2/pull/650).
MsgHdr(Mut)
(https://github.com/rust-lang/socket2/pull/650).TCP_KEEPIDLE instead of TCP_KEEPALIVE
(https://github.com/rust-lang/socket2/pull/654).Socket::only_v6 sometimes booleans are 1
byte other times it's 4 bytes
(https://github.com/rust-lang/socket2/pull/655).One column per quarter.
Added support for wasm32-wasip2.
Socket::(set_)ip_transparent_v6.Socket::set_tcp_ack_frequency.POTENTIALLY BREAKING The MSRV of windows-sys v0.61 is 1.71. To use socket2
with its MSRV of 1.70, please downgrade windows-sys to v0.60.x. This can be done
using: cargo update windows-sys --precise 0.60.2
MsgHdr and MsgHdrMut are marked as transparent meaning both have the same layout as msghdr on Unix and WSAMSG on Windows (https://github.com/rust-lang
MsgHdr and MsgHdrMut are marked as transparent meaning both have the same
layout as msghdr on Unix and WSAMSG on Windows
(https://github.com/rust-lang/socket2/pull/635).SO_NOSIGPIPE when accepting sockets, this is inherited from the
parent socket (https://github.com/rust-lang/socket2/pull/632).Socket::tcp_notsent_lowat by using the correct argument type
(https://github.com/rust-lang/socket2/pull/622).Added support for Windows Registered I/O (RIO) (https://github.com/rust-lang/socket2/pull/604).
TCP_NOTSENT_LOWAT on Linux via Socket::(set_)tcp_notsent_lowat
(https://github.com/rust-lang/socket2/pull/611).SO_BUSY_POLL on Linux via Socket::set_busy_poll
(https://github.com/rust-lang/socket2/pull/607).SockFilter::new is now a const function
(https://github.com/rust-lang/socket2/pull/609).All IPv4 methods now have a _v4 suffix, IPv6 uses _v6. TCP methods have a tcp_ prefix (looked better than a suffix).
All IPv4 methods now have a _v4 suffix, IPv6 uses _v6. TCP methods have a
tcp_ prefix (looked better than a suffix).
Furthermore we removed all types from external libraries (i.e. libc or windows-sys) from the public API, allowing us to update those without breaking the API.
Socket::freebind_ipv6 to freebind_v6
(https://github.com/rust-lang/socket2/pull/592).Socket::freebind to freebind_v4
(https://github.com/rust-lang/socket2/pull/592).Socket::original_dst to original_dst_v4
(https://github.com/rust-lang/socket2/pull/592).Socket::original_dst_ipv6 to original_dst_v6
(https://github.com/rust-lang/socket2/pull/592).c_int from std::ffi instead of from libc
(https://github.com/rust-lang/socket2/pull/599,
https://github.com/rust-lang/socket2/pull/595).SockAddr's methods now accept/return SockAddrStorage instead of
sockaddr_storage/SOCKADDR_STORAGE
(https://github.com/rust-lang/socket2/pull/576):
newtry_initas_ptras_storageSockFilter, wrapper around libc::sock_filter, argument to
Socket::attach_filter
(https://github.com/rust-lang/socket2/pull/581).Socket
(https://github.com/rust-lang/socket2/pull/592):
keepalive_time -> tcp_keepalive_timekeepalive_interval -> tcp_keepalive_intervalkeepalive_retries -> tcp_keepalive_retriesnodelay -> tcp_nodelayset_nodelay -> set_tcp_nodelaytcp_mss -> msstcp_set_mss -> set_msstcp_cork -> corktcp_set_cork -> set_corktcp_quickack -> quickacktcp_set_quickack -> set_quickackthin_linear_timeouts -> tcp_thin_linear_timeouts.Socket::(set_)priority
(https://github.com/rust-lang/socket2/pull/588).SockAddrStorage, wrapper around sockaddr_storage/SOCKADDR_STORAGE
for usage with SockAddr (instead of the types from libc/windows-sys)
(https://github.com/rust-lang/socket2/pull/576).Socket::bind_device_by_index_{v4,v6} on Android and Linux
(https://github.com/rust-lang/socket2/pull/572).Copy and Clone for InterfaceIndexOrAddress
(https://github.com/rust-lang/socket2/pull/571).OwnedFd/OwnedSocket internally for Socket
(https://github.com/rust-lang/socket2/pull/600).Add cygwin support (https://github.com/rust-lang/socket2/pull/568, https://github.com/rust-lang/socket2/pull/578).
Enable IP_BOUND_IF on illumos and Solaris (https://github.com/rust-lang/socket2/pull/561, https://github.com/rust-lang/socket2/pull/566).
IP_BOUND_IF on illumos and Solaris
(https://github.com/rust-lang/socket2/pull/561,
https://github.com/rust-lang/socket2/pull/566).Added Socket::(set_)header_included_v4 and Socket::(set_)header_included_v6 (https://github.com/rust-lang/socket2/pull/518).
Socket::(set_)header_included_v4 and
Socket::(set_)header_included_v6
(https://github.com/rust-lang/socket2/pull/518).Socket::original_dst and
Socket::original_dst_ipv6 on Windows
(https://github.com/rust-lang/socket2/pull/529).Added Socket::(set_)passcred (https://github.com/rust-lang/socket2/pull/506).
Socket::(set_)passcred
(https://github.com/rust-lang/socket2/pull/506).RecvFlags::is_confirm and RecvFlags::is_dontroute
(https://github.com/rust-lang/socket2/pull/499).MsgHdrMut::control_len
(https://github.com/rust-lang/socket2/pull/505).Added Socket::(set_)multicast_all_v{4,6} (https://github.com/rust-lang/socket2/pull/485 and https://github.com/rust-lang/socket2/pull/486).
Socket::(set_)multicast_all_v{4,6}
(https://github.com/rust-lang/socket2/pull/485 and
https://github.com/rust-lang/socket2/pull/486).Added support for Vita (https://github.com/rust-lang/socket2/pull/465).
Deprecated Socket::(bind_)device_by_index, replaced by Socket::(bind_)device_by_index_v4 for IPv4 sockets (https://github.com/rust-lang/socket2/pull/4…
Socket::(bind_)device_by_index, replaced by
Socket::(bind_)device_by_index_v4 for IPv4 sockets
(https://github.com/rust-lang/socket2/pull/432).Socket::(bind_)device_by_index_v6
(https://github.com/rust-lang/socket2/pull/432).Socket::{send,recv}msg and MsgHdr(Mut) types, wrapping sendmsg(2)
and recvmsg(2)
(https://github.com/rust-lang/socket2/pull/447).Socket::(set_)reuse_port_lb to retrieve or set SO_REUSEPORT_LB on
FreeBSD
(https://github.com/rust-lang/socket2/pull/442).Protocol::DIVERT on FreeBSD and OpenBSD
(https://github.com/rust-lang/socket2/pull/448).Socket::protocol for Windows (using WSAPROTOCOL_INFOW)
(https://github.com/rust-lang/socket2/pull/470).From<SocketAddrV{4,6}> for SockAddr nows sets ss_len on platforms that
have the fields (most BSDs)
(https://github.com/rust-lang/socket2/pull/469).ADDRESS_FAMILY for sa_family_t, this shouldn't
affect anything in practice
(https://github.com/rust-lang/socket2/pull/463).Added support for two new Android targets armv7-linux-androideabi and i686-linux-android (https://github.com/rust-lang/socket2/pull/434).
armv7-linux-androideabi and
i686-linux-android (https://github.com/rust-lang/socket2/pull/434).Socket::cookie to retrieve SO_COOKIE on Linux
(https://github.com/rust-lang/socket2/pull/437).Added Unix socket methods to SockAddr (https://github.com/rust-lang/socket2/pull/403 and https://github.com/rust-lang/socket2/pull/429).
SockAddr
(https://github.com/rust-lang/socket2/pull/403 and
https://github.com/rust-lang/socket2/pull/429).SockAddr::as_storage
(https://github.com/rust-lang/socket2/pull/417).SockAddr::set_length
(https://github.com/rust-lang/socket2/pull/428).Protocol::UDPLITE
(https://github.com/rust-lang/socket2/pull/427).Type::cloexec for Redox and Solaris (https://github.com/rust-lang/socket2/pull/398).
Type::cloexec for Redox and Solaris
(https://github.com/rust-lang/socket2/pull/398).BREAKING SockAddr::init is renamed to try_init to indicate it can fail (https://github.com/rust-lang/socket2/pull/328).
SockAddr::init is renamed to try_init to indicate it can fail
(https://github.com/rust-lang/socket2/pull/328).Result from SockAddr::vsock, it can't
fail (https://github.com/rust-lang/socket2/pull/328).From<S> is now implemented using the I/O traits AsFd and
AsRawSocket
(https://github.com/rust-lang/socket2/pull/325):SockAddr::vsock_addr SockAddr::as_vsock_addr to match
the IPv4 and IPv6 methods
(https://github.com/rust-lang/socket2/pull/334).From<SocketAddrV{4,6}> implementation for SockAddr
(https://github.com/rust-lang/socket2/pull/335).AsFd for Socket (Unix only).From<OwnedFd> for Socket (Unix only).From<Socket> for OwnedFd (Unix only).AsSocket for Socket (Windows only).From<OwnedSocket> for Socket (Windows only).From<Socket> for OwnedSocket (Windows only).SockAddr::is_ipv{4,6} and SockAddr::domain
(https://github.com/rust-lang/socket2/pull/334).Socket::nonblocking
(https://github.com/rust-lang/socket2/pull/348).Socket::original_dst(_ipv6)
(https://github.com/rust-lang/socket2/pull/360).Socket::(set_)recv_tclass_v6 and Socket::(set_)tclass_v6
(https://github.com/rust-lang/socket2/pull/364).Socket::(set_)tcp_congestion
(https://github.com/rust-lang/socket2/pull/371).Socket::(set_)dccp_serviceSocket::dccp_available_ccidsSocket::dccp_qpolicy_txqlenSocket::dccp_recv_cscovSocket::dccp_send_cscovSocket::dccp_server_timewaitSocket::dccp_server_timewaitSocket::dccp_tx_ccidSocket::dccp_xx_ccidSocket::set_dccp_ccidSocket::set_dccp_qpolicy_txqlenSocket::set_dccp_recv_cscovSocket::set_dccp_send_cscovSocket::set_dccp_server_timewaitSocket::dccp_cur_mpsSocket::peek_send
(https://github.com/rust-lang/socket2/pull/389).Protocol::MPTCP
(https://github.com/rust-lang/socket2/pull/349).Protocol::SCTP
(https://github.com/rust-lang/socket2/pull/356).Protocol::DCCP
(https://github.com/rust-lang/socket2/pull/359).Type::DCCP
(https://github.com/rust-lang/socket2/pull/359).Eq and Hash for SockAddr
(https://github.com/rust-lang/socket2/pull/374).Fixed compilation with the all on QNX Neutrino (https://github.com/rust-lang/socket2/pull/419).
all on QNX Neutrino
(https://github.com/rust-lang/socket2/pull/419).Fixed compilation on Windows (https://github.com/rust-lang/socket2/pull/409).
This release was broken for Windows.
This release was broken for Windows.
Socket::peek_sender (backport)
(https://github.com/rust-lang/socket2/pull/404).Fixes compilation on OpenBSD (https://github.com/rust-lang/socket2/pull/344).
Reverted back to the winapi dependency as switch to windows-sys was a breaking change (https://github.com/rust-lang/socket2/pull/340). Note that we'll…
winapi dependency as switch to windows-sys was a
breaking change (https://github.com/rust-lang/socket2/pull/340).
Note that we'll will switch to windows-sys in v0.5 .Replace winapi dependency with windows-sys (https://github.com/rust-lang/socket2/pull/303).
winapi dependency with windows-sys
(https://github.com/rust-lang/socket2/pull/303).Socket::join_ssm_v4 and Socket::leave_ssm_v4
(https://github.com/rust-lang/socket2/pull/298).Socket::set_recv_tos and Socket::recv_tos
(https://github.com/rust-lang/socket2/pull/299).Libc v0.2.114 fixed an issue where ip_mreqn where was not defined for Linux s390x.
ip_mreqn where was not defined for Linux
s390x.Socket::set_fib: sets SO_SETFIB (https://github.com/rust-lang/socket2/pull/271).
Socket::set_fib: sets SO_SETFIB (https://github.com/rust-lang/socket2/pull/271).Socket::attach_filter, SO_ATTACH_FILTER (https://github.com/rust-lang/socket2/commit/6601ed132b37d6e9d178b34918bfb0b236800232).Socket::detach_filter, SO_DETACH_FILTER (https://github.com/rust-lang/socket2/commit/6601ed132b37d6e9d178b34918bfb0b236800232).Socket::{header_included, set_header_included}: sets or gets IP_HDRINCL
(https://github.com/rust-lang/socket2/commit/f9e882ee53c0b4e89c5043b6d709af95c9db5599).Socket::{cork, set_cork}: sets or gets TCP_CORK
(https://github.com/rust-lang/socket2/commit/50f31f18aac8fd6ef277df2906adeeed9fa391de).Socket::{quickack, set_quickack}: sets or gets TCP_QUICKACK
(https://github.com/rust-lang/socket2/commit/849eee2abc5d5170d2d3bc635386a2ba13b04530).Socket::{thin_linear_timeouts, set_thin_linear_timeouts}: sets or gets
TCP_THIN_LINEAR_TIMEOUTS
(https://github.com/rust-lang/socket2/commit/24c231ca463a17f51e53e7a554c7915a95bdbcc7).Socket::{join_multicast_v4_n, leave_multicast_v4_n}: extends the existing
multicast API by allowing an index to be used (in addition to an address)
(https://github.com/rust-lang/socket2/commit/750f83618b967c620bbfdf6ca04de7362bdb42b5).Socket::(set_)freebind_ipv6, getter and setter for IPV6_FREEBIND.
Socket::(set_)freebind_ipv6, getter and setter for IPV6_FREEBIND.Socket::(set_)freebind.Enable Socket::type on all platforms.
SockAddr::newTCP_USER_TIMEOUT.IP_BOUND_IF.IP_TRANSPARENT.Socket::type on all platforms.KEEPINTVL/KEEPCNT).SockRef::from, and the improper use.SockRef::from to ensure the raw socket valid.SockAddr::unix.New all feature: enables API that is not available on all tier 1 platforms.
all feature: enables API that is not available on all tier 1 platforms.SockRef type: used to create a reference to an existing socket, e.g.
std::net::TcpStream, making all methods of Socket available on it.Socket::recv_vectored, Socket::recv_with_flags.Socket::recv_from_vectored, Socket::recv_from_vectored_with_flags.Socket::send_vectored, Socket::send_vectored_with_flags.Socket::send_to_vectored, Socket::send_to_vectored_with_flags.Read and Write implementations.Socket::new_raw, Socket::pair_raw and Socket::accept_raw methods
that don't set common flags, such as the close-on-exec flag.Socket::accept4: accept4(2) system call.Socket::sendfile: the sendfile(2) system call.Socket::set_cloexec: set the close-on-exec flag on Unix.Socket::set_no_inherit: set inherit handle flag on Windows.Socket::set_nosigpipe: set SO_NOSIGPIPE on Apple targets.Socket::set_mark and Socket::mark, setting/getting the SO_MARK socket
option.Socket::set_cpu_affinity and Socket::cpu_affinity, setting/getting the
SO_INCOMING_CPU socket option.Socket::set_mss and Socket::mss, setting/getting the TCP_MAXSEG socket
option.Socket::set_freebind and Socket::freebind, setting/getting the
IP_FREEBIND socket option.Socket::bind_device and Socket::device, setting/getting the
SO_BINDTODEVICE socket option.Socket::keepalive_time,Socket::keepalive_interval,Socket::keepalive_retries,Socket::set_tcp_keepalive.Socket::is_listener getting the SO_ACCEPTCONN socket option.Socket::domain getting the SO_DOMAIN socket option.Socket::protocol getting the SO_PROTOCOL socket option.Socket::type getting the SO_TYPE socket option.Domain::for_address: the correct Domain for a std::net::SocketAddr.Type::nonblocking: set SOCK_NONBLOCK.Type::cloexec: set SOCK_CLOEXEC.Type::no_inherit: set HANDLE_FLAG_INHERIT.SockAddr::init: initialises a SockAddr.MaybeUninitSlice type: a version of IoSliceMut that allows the buffer to
be uninitialised, used in Socket::recv_vectored and related functions.RecvFlags type: provides additional information about incoming messages,
returned by Socket::recv_vectored and related functions.TcpKeepalive type: configuration type for a socket's TCP keepalive
parameters.Domain::ipv4 => Domain::IPV4.Domain::ipv6 => Domain::IPV4.Domain::unix => Domain::UNIX.Domain::packet => Domain::PACKET.Type::stream => Type::STREAM.Type::dgram => Type::DGRAM.Type::seqpacket => Type::SEQPACKET.Type::raw => Type::RAW.Protocol::icmpv4 => Protocol::ICMPV4.Protocol::icmpv6 => Protocol::ICMPV6.Protocol::tcp => Protocol::TCP.Protocol::udp => Protocol::UDP.Socket::recv, Socket::recv_vectored
and related methods to accept uninitialised buffers. The Read implementation
can be used to read into initialised buffers.SockAddr::as_std to as_socket.SockAddr::as_inet to as_socket_ipv4.SockAddr::as_inet6 to as_socket_ipv6.accept4(2) with SOCK_CLOEXEC in Socket::accept, reducing the amount
of system calls required.Read implementation now calls recv(2) rather than read(2).impl block for the Socket type to create groupings for setting
and getting different level socket options using
setsockopt(2)/getsockopt(2).winapi depdency to version 0.3.9 and dropped unused features.-rs suffix from the repository name.SockAddr::from_raw_parts, use SockAddr::init instead.Socket::into_* functions and replaced them with a From
implementation:
Socket::into_tcp_stream => TcpStream::from(socket).Socket::into_tcp_listener => TcpListener::from(socket).Socket::into_udp_socket => UdpSocket::from(socket).Socket::into_unix_stream => UnixStream::from(socket).Socket::into_unix_listener => UnixListener::from(socket).Socket::into_unix_datagram => UnixDatagram::from(socket).cfg-if dependency.redox_syscall depdency.recv_from in Socket::recv_from_with_flags (called recv
previously).send_to in Socket::send_to_with_flags (called recv
previously).Socket::send_with_flags and
Socket::send_out_of_band.IPPROTO_IPV6 in Socket::join_multicast_v6 on Windows.c_int instead of i32 where appropriate.Socket::device now returns a Vec<u8> rather than CString.Socket::bind_device now accepts a &[u8] rather than &CStr.Socket::connect_timeout was added back.Socket::set_cpu_affinity and Socket::cpu_affinity to use an
immutable reference.SO_LINGER_SEC on macOS for Socket::get/set_linger.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Don't assume the memory layout of std::SocketAddr.
std::net::SocketAddr.Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →