mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
Update to mio 0.6
This commit is contained in:
+2
-2
@@ -14,9 +14,9 @@ the rest of the tokio crates.
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
futures = { git = "https://github.com/alexcrichton/futures-rs" }
|
futures = { git = "https://github.com/alexcrichton/futures-rs" }
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
mio = { git = "https://github.com/carllerche/mio" }
|
mio = "0.6"
|
||||||
scoped-tls = "0.1.0"
|
scoped-tls = "0.1.0"
|
||||||
slab = { git = "https://github.com/carllerche/slab" }
|
slab = "0.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.3"
|
env_logger = "0.3"
|
||||||
|
|||||||
+92
-7
@@ -1,5 +1,5 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io::{self, ErrorKind, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::net::{self, SocketAddr, Shutdown};
|
use std::net::{self, SocketAddr, Shutdown};
|
||||||
|
|
||||||
@@ -115,6 +115,44 @@ impl TcpListener {
|
|||||||
})
|
})
|
||||||
}).boxed()
|
}).boxed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the value for the `IP_TTL` option on this socket.
|
||||||
|
///
|
||||||
|
/// This value sets the time-to-live field that is used in every packet sent
|
||||||
|
/// from this socket.
|
||||||
|
pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {
|
||||||
|
self.io.get_ref().set_ttl(ttl)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the value of the `IP_TTL` option for this socket.
|
||||||
|
///
|
||||||
|
/// For more information about this option, see [`set_ttl`][link].
|
||||||
|
///
|
||||||
|
/// [link]: #method.set_ttl
|
||||||
|
pub fn ttl(&self) -> io::Result<u32> {
|
||||||
|
self.io.get_ref().ttl()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the value for the `IPV6_V6ONLY` option on this socket.
|
||||||
|
///
|
||||||
|
/// If this is set to `true` 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.
|
||||||
|
///
|
||||||
|
/// If this is set to `false` then the socket can be used to send and
|
||||||
|
/// receive packets from an IPv4-mapped IPv6 address.
|
||||||
|
pub fn set_only_v6(&self, only_v6: bool) -> io::Result<()> {
|
||||||
|
self.io.get_ref().set_only_v6(only_v6)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the value of the `IPV6_V6ONLY` option for this socket.
|
||||||
|
///
|
||||||
|
/// For more information about this option, see [`set_only_v6`][link].
|
||||||
|
///
|
||||||
|
/// [link]: #method.set_only_v6
|
||||||
|
pub fn only_v6(&self) -> io::Result<bool> {
|
||||||
|
self.io.get_ref().only_v6()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for TcpListener {
|
impl fmt::Debug for TcpListener {
|
||||||
@@ -252,9 +290,56 @@ impl TcpStream {
|
|||||||
self.io.get_ref().set_nodelay(nodelay)
|
self.io.get_ref().set_nodelay(nodelay)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the keepalive time in seconds for this socket.
|
/// Gets the value of the `TCP_NODELAY` option on this socket.
|
||||||
pub fn set_keepalive_s(&self, seconds: Option<u32>) -> io::Result<()> {
|
///
|
||||||
self.io.get_ref().set_keepalive(seconds)
|
/// For more information about this option, see [`set_nodelay`][link].
|
||||||
|
///
|
||||||
|
/// [link]: #method.set_nodelay
|
||||||
|
pub fn nodelay(&self) -> io::Result<bool> {
|
||||||
|
self.io.get_ref().nodelay()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets whether keepalive messages are enabled to be sent on this socket.
|
||||||
|
///
|
||||||
|
/// On Unix, this option will set the `SO_KEEPALIVE` as well as the
|
||||||
|
/// `TCP_KEEPALIVE` or `TCP_KEEPIDLE` option (depending on your platform).
|
||||||
|
/// On Windows, this will set the `SIO_KEEPALIVE_VALS` option.
|
||||||
|
///
|
||||||
|
/// If `None` is specified then keepalive messages are disabled, otherwise
|
||||||
|
/// the number of milliseconds specified will be the time to remain idle
|
||||||
|
/// before sending a TCP keepalive probe.
|
||||||
|
///
|
||||||
|
/// Some platforms specify this value in seconds, so sub-second millisecond
|
||||||
|
/// specifications may be omitted.
|
||||||
|
pub fn set_keepalive_ms(&self, keepalive: Option<u32>) -> io::Result<()> {
|
||||||
|
self.io.get_ref().set_keepalive_ms(keepalive)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether keepalive messages are enabled on this socket, and if so
|
||||||
|
/// the amount of milliseconds between them.
|
||||||
|
///
|
||||||
|
/// For more information about this option, see [`set_keepalive_ms`][link].
|
||||||
|
///
|
||||||
|
/// [link]: #method.set_keepalive_ms
|
||||||
|
pub fn keepalive_ms(&self) -> io::Result<Option<u32>> {
|
||||||
|
self.io.get_ref().keepalive_ms()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the value for the `IP_TTL` option on this socket.
|
||||||
|
///
|
||||||
|
/// This value sets the time-to-live field that is used in every packet sent
|
||||||
|
/// from this socket.
|
||||||
|
pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {
|
||||||
|
self.io.get_ref().set_ttl(ttl)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the value of the `IP_TTL` option for this socket.
|
||||||
|
///
|
||||||
|
/// For more information about this option, see [`set_ttl`][link].
|
||||||
|
///
|
||||||
|
/// [link]: #method.set_ttl
|
||||||
|
pub fn ttl(&self) -> io::Result<u32> {
|
||||||
|
self.io.get_ref().ttl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,9 +361,9 @@ impl Future for TcpStreamNew {
|
|||||||
// If all that succeeded then we ship everything on up.
|
// If all that succeeded then we ship everything on up.
|
||||||
match stream.io.poll_write() {
|
match stream.io.poll_write() {
|
||||||
Poll::Ok(()) => {
|
Poll::Ok(()) => {
|
||||||
match stream.io.get_ref().take_socket_error() {
|
match stream.io.get_ref().take_error() {
|
||||||
Ok(()) => return Poll::Ok(stream),
|
Ok(Some(e)) => return Poll::Err(e),
|
||||||
Err(ref e) if e.kind() == ErrorKind::WouldBlock => {}
|
Ok(None) => return Poll::Ok(stream),
|
||||||
Err(e) => return Poll::Err(e),
|
Err(e) => return Poll::Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user