👕 refactor: use full address for udp_over_tcp client instead of just port
parent
fd3c85fccd
commit
8a302f3049
|
@ -20,7 +20,7 @@ use crate::loops;
|
|||
pub struct Config {
|
||||
pub udp_eph_port: u16,
|
||||
pub udp_local_server_port: u16,
|
||||
pub tcp_server_port: u16,
|
||||
pub tcp_server_addr: SocketAddr,
|
||||
}
|
||||
|
||||
pub async fn main (cfg: Config) -> anyhow::Result <()> {
|
||||
|
@ -28,7 +28,7 @@ pub async fn main (cfg: Config) -> anyhow::Result <()> {
|
|||
udp_sock.connect ((Ipv4Addr::LOCALHOST, cfg.udp_eph_port)).await?;
|
||||
|
||||
let tcp_sock = TcpSocket::new_v4 ()?;
|
||||
let tcp_conn = tcp_sock.connect (SocketAddr::V4 (SocketAddrV4::new (Ipv4Addr::LOCALHOST, cfg.tcp_server_port))).await?;
|
||||
let tcp_conn = tcp_sock.connect (cfg.tcp_server_addr).await?;
|
||||
let (tcp_read, tcp_write) = tcp_conn.into_split ();
|
||||
|
||||
let tx_task;
|
||||
|
|
|
@ -10,6 +10,14 @@ Terminals A and C should be connected through the UDP-over-TCP connection
|
|||
|
||||
*/
|
||||
|
||||
use std::{
|
||||
net::{
|
||||
Ipv4Addr,
|
||||
SocketAddr,
|
||||
SocketAddrV4,
|
||||
},
|
||||
};
|
||||
|
||||
use tokio::{
|
||||
runtime,
|
||||
spawn,
|
||||
|
@ -50,7 +58,7 @@ async fn async_main () -> anyhow::Result <()> {
|
|||
let client_cfg = client::Config {
|
||||
udp_eph_port: PORT_0,
|
||||
udp_local_server_port: PORT_1,
|
||||
tcp_server_port: PORT_2,
|
||||
tcp_server_addr: SocketAddr::V4 (SocketAddrV4::new (Ipv4Addr::LOCALHOST, PORT_2)),
|
||||
};
|
||||
let client_task = spawn (client::main (client_cfg));
|
||||
|
||||
|
|
Loading…
Reference in New Issue