Expand description
Send/receive data to/from a TCP server and associated types.
§Usage
let hostname = "github.com";
// let ip_address: IpAddress = [140, 82, 114, 3]; // github.com
let port: Port = 80;
let mode: TransportMode = TransportMode::Tcp;
if let Err(e) = TcpClient::build(&mut wifi).connect(
hostname,
port,
mode,
&mut delay,
&mut |tcp_client| {
defmt::info!(
"TCP connection to {:?}:{:?} successful",
hostname,
port
);
defmt::info!("Hostname: {:?}", tcp_client.server_hostname());
defmt::info!("Sending HTTP Document: {:?}", http_document.as_str());
match tcp_client.send_data(&http_document) {
Ok(response) => {
defmt::info!("Response: {:?}", response)
}
Err(e) => {
defmt::error!("Response error: {:?}", e)
}
}
},
) {
defmt::error!(
"TCP connection to {:?}:{:?} failed: {:?}",
hostname,
port,
e
);
}
Structs§
- TcpClient
- A client type that connects to and performs send/receive operations with a remote server using the TCP protocol.