pub fn new_with_cfg(addr: &str, cfg: Config) -> io::Result<Transport> {
        let stream = match cfg.tcp_connect_timeout {
            Some(timeout) => {
                // Call to connect_timeout needs to be done on a single address
                let mut socket_addrs = (addr, cfg.tcp_port).to_socket_addrs()?;
                TcpStream::connect_timeout(&socket_addrs.next().unwrap(), timeout)
            }
            None => TcpStream::connect((addr, cfg.tcp_port)),
        };

        match stream {
            Ok(s) => {
                s.set_read_timeout(cfg.tcp_read_timeout)?;
                s.set_write_timeout(cfg.tcp_write_timeout)?;
                s.set_nodelay(true)?;
                Ok(Transport {
                    tid: 0,
                    uid: cfg.modbus_uid,
                    stream: s,
                })
            }
            Err(e) => Err(e),
        }
    }
/// Create a new context object and connect it to `addr` on port `port`
Create a new context object and connect it to `addr` on port `port`
Create a new context object and connect it to ` addr ` on port ` port `
pub fn new_with_cfg(addr: &str, cfg: Config) -> io::Result<Transport> {
        let stream = match cfg.tcp_connect_timeout {
            Some(timeout) => {
                // Call to connect_timeout needs to be done on a single address
                let mut socket_addrs = (addr, cfg.tcp_port).to_socket_addrs()?;
                TcpStream::connect_timeout(&socket_addrs.next().unwrap(), timeout)
            }
            None => TcpStream::connect((addr, cfg.tcp_port)),
        };
        match stream {
            Ok(s) => {
                s.set_read_timeout(cfg.tcp_read_timeout)?;
                s.set_write_timeout(cfg.tcp_write_timeout)?;
                s.set_nodelay(true)?;
                Ok(Transport {
                    tid: 0,
                    uid: cfg.modbus_uid,
                    stream: s,
                })
            }
            Err(e) => Err(e),
        }
    }
pub fn new_with_cfg ( addr : & str , cfg : Config ) -> io :: Result < Transport > { let stream = match cfg . tcp_connect_timeout { Some ( timeout ) => { // Call to connect_timeout needs to be done on a single address let mut socket_addrs = ( addr , cfg . tcp_port ) . to_socket_addrs ( ) ? ; TcpStream :: connect_timeout ( & socket_addrs . next ( ) . unwrap ( ) , timeout ) } None => TcpStream :: connect ( ( addr , cfg . tcp_port ) ) , } ; match stream { Ok ( s ) => { s . set_read_timeout ( cfg . tcp_read_timeout ) ? ; s . set_write_timeout ( cfg . tcp_write_timeout ) ? ; s . set_nodelay ( true ) ? ; Ok ( Transport { tid : 0 , uid : cfg . modbus_uid , stream : s , } ) } Err ( e ) => Err ( e ) , } }
Create a new context object and connect it to `addr` on port `port`
Create a new context object and connect it to ` addr ` on port ` port `
addr
&str
cfg
Config
addr
&str
cfg
Config