Struct asyncio::ip::Tcp
[−]
[src]
pub struct Tcp { /* fields omitted */ }
The Transmission Control Protocol.
Examples
In this example, Create a TCP server socket and accept a connection by client.
use asyncio::{IoContext, Protocol, Endpoint}; use asyncio::ip::{IpProtocol, Tcp, TcpEndpoint, TcpSocket, TcpListener}; use asyncio::socket_base::ReuseAddr; let ctx = &IoContext::new().unwrap(); let ep = TcpEndpoint::new(Tcp::v4(), 12345); let soc = TcpListener::new(ctx, ep.protocol()).unwrap(); soc.set_option(ReuseAddr::new(true)).unwrap(); soc.bind(&ep).unwrap(); soc.listen().unwrap(); let (acc, ep) = soc.accept().unwrap();
Examples
In this example, Create a TCP client socket and connect to TCP server.
use asyncio::{IoContext, Protocol, Endpoint}; use asyncio::ip::{IpProtocol, IpAddrV4, Tcp, TcpEndpoint, TcpSocket}; let ctx = &IoContext::new().unwrap(); let soc = TcpSocket::new(ctx, Tcp::v4()).unwrap(); let _ = soc.connect(&TcpEndpoint::new(IpAddrV4::loopback(), 12345));
Examples
In this example, Resolve a TCP hostname and connect to TCP server.
use asyncio::{IoContext, Protocol, Endpoint}; use asyncio::ip::{Tcp, TcpEndpoint, TcpSocket, TcpResolver}; let ctx = &IoContext::new().unwrap(); let re = TcpResolver::new(ctx); let (soc, ep) = re.connect(("localhost", "12345")).unwrap();
Trait Implementations
impl Clone for Tcp
[src]
fn clone(&self) -> Tcp
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Eq for Tcp
[src]
impl PartialEq for Tcp
[src]
fn eq(&self, __arg_0: &Tcp) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Tcp) -> bool
This method tests for !=
.
impl Ord for Tcp
[src]
fn cmp(&self, __arg_0: &Tcp) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl PartialOrd for Tcp
[src]
fn partial_cmp(&self, __arg_0: &Tcp) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Tcp) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Tcp) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Tcp) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Tcp) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Protocol for Tcp
[src]
type Endpoint = IpEndpoint<Self>
fn family_type(&self) -> i32
Reurns a value suitable for passing as the domain argument.
fn socket_type(&self) -> i32
Returns a value suitable for passing as the type argument.
fn protocol_type(&self) -> i32
Returns a value suitable for passing as the protocol argument.
unsafe fn uninitialized(&self) -> Self::Endpoint
impl IpProtocol for Tcp
[src]
fn v4() -> Tcp
Represents a TCP for IPv4.
Examples
use asyncio::Endpoint; use asyncio::ip::{IpProtocol, IpAddrV4, Tcp, TcpEndpoint}; let ep = TcpEndpoint::new(IpAddrV4::any(), 0); assert_eq!(Tcp::v4(), ep.protocol());
fn v6() -> Tcp
Represents a TCP for IPv6.
Examples
use asyncio::Endpoint; use asyncio::ip::{IpProtocol, IpAddrV6, Tcp, TcpEndpoint}; let ep = TcpEndpoint::new(IpAddrV6::any(), 0); assert_eq!(Tcp::v6(), ep.protocol());