[−][src]Struct libuv::handles::streams::tcp::TcpHandle
TCP handles are used to represent both TCP streams and servers.
Implementations
impl TcpHandle
[src]
pub fn new(r#loop: &Loop) -> Result<TcpHandle>
[src]
Initialize the handle. No socket is created as of yet.
pub fn new_ex(r#loop: &Loop, flags: TcpFlags) -> Result<TcpHandle>
[src]
Initialize the handle with the specified flags. A socket will be created for the given domain. If the specified domain is AF_UNSPEC no socket is created, just like new().
pub fn nodelay(&mut self, enable: bool) -> Result<()>
[src]
Enable TCP_NODELAY, which disables Nagle’s algorithm.
pub fn keepalive(&mut self, enable: bool, delay: u32) -> Result<()>
[src]
Enable / disable TCP keep-alive. delay is the initial delay in seconds, ignored when enable is zero.
After delay has been reached, 10 successive probes, each spaced 1 second from the previous one, will still happen. If the connection is still lost at the end of this procedure, then the handle is destroyed with a ETIMEDOUT error passed to the corresponding callback.
pub fn simultaneous_accepts(&mut self, enable: bool) -> Result<()>
[src]
Enable / disable simultaneous asynchronous accept requests that are queued by the operating system when listening for new TCP connections.
This setting is used to tune a TCP server for the desired performance. Having simultaneous accepts can significantly improve the rate of accepting connections (which is why it is enabled by default) but may lead to uneven load distribution in multi-process setups.
pub fn bind(
&mut self,
addr: &SocketAddr,
flags: TcpBindFlags
) -> Result<(), Box<dyn Error>>
[src]
&mut self,
addr: &SocketAddr,
flags: TcpBindFlags
) -> Result<(), Box<dyn Error>>
Bind the handle to an address and port.
When the port is already taken, you can expect to see an EADDRINUSE error from either bind(), listen() or connect(). That is, a successful call to this function does not guarantee that the call to listen() or connect() will succeed as well.
flags can contain IPV6ONLY, in which case dual-stack support is disabled and only IPv6 is used.
pub fn getsockname(&self) -> Result<SocketAddr, Box<dyn Error>>
[src]
Get the current address to which the handle is bound.
pub fn getpeername(&self) -> Result<SocketAddr, Box<dyn Error>>
[src]
Get the address of the peer connected to the handle.
pub fn connect<CB: Into<ConnectCB<'static>>>(
&mut self,
addr: &SocketAddr,
cb: CB
) -> Result<ConnectReq, Box<dyn Error>>
[src]
&mut self,
addr: &SocketAddr,
cb: CB
) -> Result<ConnectReq, Box<dyn Error>>
Establish an IPv4 or IPv6 TCP connection.
On Windows if the addr is initialized to point to an unspecified address (0.0.0.0 or ::) it will be changed to point to localhost. This is done to match the behavior of Linux systems.
The callback is made when the connection has been established or when a connection error happened.
pub fn close_reset<CB: Into<CloseCB<'static>>>(&mut self, cb: CB) -> Result<()>
[src]
Resets a TCP connection by sending a RST packet. This is accomplished by setting the SO_LINGER socket option with a linger interval of zero and then calling close(). Due to some platform inconsistencies, mixing of shutdown() and close_reset() calls is not allowed.
Trait Implementations
impl Clone for TcpHandle
[src]
impl Copy for TcpHandle
[src]
impl From<TcpHandle> for StreamHandle
[src]
fn from(tcp: TcpHandle) -> StreamHandle
[src]
impl From<TcpHandle> for Handle
[src]
impl HandleTrait for TcpHandle
[src]
fn is_active(&self) -> bool
[src]
fn is_closing(&self) -> bool
[src]
fn close<CB: Into<CloseCB<'static>>>(&mut self, cb: CB)
[src]
fn ref(&mut self)
[src]
fn unref(&mut self)
[src]
fn has_ref(&self) -> bool
[src]
fn send_buffer_size(&mut self, value: i32) -> Result<i32>
[src]
fn recv_buffer_size(&mut self, value: i32) -> Result<i32>
[src]
fn get_fileno(&self) -> Result<OsFile>
[src]
fn get_loop(&self) -> Loop
[src]
fn get_type(&self) -> HandleType
[src]
impl StreamTrait for TcpHandle
[src]
fn shutdown<CB: Into<ShutdownCB<'static>>>(
&mut self,
cb: CB
) -> Result<ShutdownReq>
[src]
&mut self,
cb: CB
) -> Result<ShutdownReq>
fn listen<CB: Into<ConnectionCB<'static>>>(
&mut self,
backlog: i32,
cb: CB
) -> Result<()>
[src]
&mut self,
backlog: i32,
cb: CB
) -> Result<()>
fn accept(&mut self, client: &mut StreamHandle) -> Result<()>
[src]
fn read_start<ACB: Into<AllocCB<'static>>, RCB: Into<ReadCB<'static>>>(
&mut self,
alloc_cb: ACB,
read_cb: RCB
) -> Result<()>
[src]
&mut self,
alloc_cb: ACB,
read_cb: RCB
) -> Result<()>
fn read_stop(&mut self) -> Result<()>
[src]
fn write<CB: Into<WriteCB<'static>>>(
&mut self,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
[src]
&mut self,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
fn write2<CB: Into<WriteCB<'static>>>(
&mut self,
send_handle: &StreamHandle,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
[src]
&mut self,
send_handle: &StreamHandle,
bufs: &[impl BufTrait],
cb: CB
) -> Result<WriteReq>
fn try_write(&mut self, bufs: &[impl BufTrait]) -> Result<i32>
[src]
fn is_readable(&self) -> bool
[src]
fn is_writable(&self) -> bool
[src]
fn set_blocking(&mut self, blocking: bool) -> Result<()>
[src]
fn get_write_queue_size(&self) -> usize
[src]
impl ToHandle for TcpHandle
[src]
impl ToStream for TcpHandle
[src]
fn to_stream(&self) -> StreamHandle
[src]
impl TryFrom<Handle> for TcpHandle
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(handle: Handle) -> Result<Self, Self::Error>
[src]
impl TryFrom<StreamHandle> for TcpHandle
[src]
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(stream: StreamHandle) -> Result<Self, Self::Error>
[src]
Auto Trait Implementations
impl RefUnwindSafe for TcpHandle
impl !Send for TcpHandle
impl !Sync for TcpHandle
impl Unpin for TcpHandle
impl UnwindSafe for TcpHandle
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,