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::{IoService, Protocol, Endpoint}; use asyncio::ip::{Tcp, TcpEndpoint, TcpSocket, TcpListener}; use asyncio::socket_base::ReuseAddr; let io = &IoService::new(); let ep = TcpEndpoint::new(Tcp::v4(), 12345); let soc = TcpListener::new(io, 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::{IoService, Protocol, Endpoint}; use asyncio::ip::{Tcp, TcpEndpoint, TcpSocket, IpAddrV4}; let io = &IoService::new(); let soc = TcpSocket::new(io, 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::{IoService, Protocol, Endpoint}; use asyncio::ip::{Tcp, TcpEndpoint, TcpSocket, TcpResolver}; let io = &IoService::new(); let re = TcpResolver::new(io); let (soc, ep) = re.connect(("localhost", "12345")).unwrap();
Methods
impl Tcp
[src]
fn v4() -> Tcp
Represents a TCP for IPv4.
Examples
use asyncio::Endpoint; use asyncio::ip::{Tcp, TcpEndpoint, IpAddrV4}; 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::{Tcp, TcpEndpoint, IpAddrV6}; let ep = TcpEndpoint::new(IpAddrV6::any(), 0); assert_eq!(Tcp::v6(), ep.protocol());
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 Debug for Tcp
[src]
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.