diff --git a/src/conn.rs b/src/conn.rs index c71ec83..5d34548 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -23,24 +23,9 @@ pub type NetConnection = Connection, BufferedWriter, BufferedWriter> { /// Creates a thread-safe TCP connection to the specified server. #[experimental] - pub fn connect(host: &str, port: u16) -> IoResult { - Connection::connect_internal(host, port, None) - } - - /// Creates a thread-safe TCP connection to the specified server with a given timeout in - /// milliseconds. - #[experimental] - pub fn connect_with_timeout(host: &str, port: u16, timeout_ms: u64) - -> IoResult { - Connection::connect_internal(host, port, Some(timeout_ms)) - } - - /// Creates a thread-safe TCP connection with an optional timeout. - #[experimental] - fn connect_internal(host: &str, port: u16, timeout_ms: Option) + pub fn connect(host: &str, port: u16) -> IoResult { - let mut socket = try!(TcpStream::connect(format!("{}:{}", host, port)[])); - socket.set_timeout(timeout_ms); + let socket = try!(TcpStream::connect(format!("{}:{}", host, port)[])); Ok(Connection::new( BufferedReader::new(NetStream::UnsecuredTcpStream(socket.clone())), BufferedWriter::new(NetStream::UnsecuredTcpStream(socket)) @@ -50,33 +35,9 @@ impl Connection, BufferedWriter> { /// Creates a thread-safe TCP connection to the specified server over SSL. /// If the library is compiled without SSL support, this method panics. #[experimental] - pub fn connect_ssl(host: &str, port: u16) -> IoResult { - Connection::connect_ssl_internal(host, port, None) - } - - /// Creates a thread-safe TCP connection to the specificed server over SSL with a given timeout - /// in milliseconds. If the library is compiled without SSL support, this method panics. - #[experimental] - pub fn connect_ssl_with_timeout(host: &str, port: u16, timeout_ms: u64) - -> IoResult { - Connection::connect_ssl_internal(host, port, Some(timeout_ms)) - } - - /// Panics because SSL support was not included at compilation. - #[experimental] - #[cfg(not(feature = "ssl"))] - fn connect_ssl_internal(host: &str, port: u16, _: Option) - -> IoResult { - panic!("Cannot connect to {}:{} over SSL without compiling with SSL support.", host, port) - } - - /// Creates a thread-safe TCP connection over SSL with an optional timeout. - #[experimental] #[cfg(feature = "ssl")] - fn connect_ssl_internal(host: &str, port: u16, timeout_ms: Option) - -> IoResult { - let mut socket = try!(TcpStream::connect(format!("{}:{}", host, port)[])); - socket.set_timeout(timeout_ms); + pub fn connect_ssl(host: &str, port: u16) -> IoResult { + let socket = try!(TcpStream::connect(format!("{}:{}", host, port)[])); let ssl = try!(ssl_to_io(SslContext::new(SslMethod::Tlsv1))); let ssl_socket = try!(ssl_to_io(SslStream::new(&ssl, socket))); Ok(Connection::new( @@ -85,6 +46,15 @@ impl Connection, BufferedWriter> { )) } + /// Creates a thread-safe TCP connection to the specified server over SSL. + /// If the library is compiled without SSL support, this method panics. + #[experimental] + #[cfg(not(feature = "ssl"))] + pub fn connect_ssl(host: &str, port: u16) + -> IoResult { + panic!("Cannot connect to {}:{} over SSL without compiling with SSL support.", host, port) + } + /// Sets the keepalive for the network stream. #[experimental] pub fn set_keepalive(&self, delay_in_seconds: Option) -> IoResult<()> { diff --git a/src/server/mod.rs b/src/server/mod.rs index 72e5823..5002a3c 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -47,13 +47,6 @@ impl IrcServer, BufferedWriter> { IrcServer::from_config(try!(Config::load_utf8(config))) } - /// Creates a new IRC server connection from the configuration at the specified path with the - /// specified timeout in milliseconds, connecting immediately. - #[experimental] - pub fn with_timeout(config: &str, timeout_ms: u64) -> IoResult { - IrcServer::from_config_with_timeout(try!(Config::load_utf8(config)), timeout_ms) - } - /// Creates a new IRC server connection from the specified configuration, connecting /// immediately. #[experimental] @@ -67,20 +60,6 @@ impl IrcServer, BufferedWriter> { alt_nick_index: RWLock::new(0u) }) } - /// Creates a new IRC server connection from the specified configuration with the specified - /// timeout in milliseconds, connecting - /// immediately. - #[experimental] - pub fn from_config_with_timeout(config: Config, timeout_ms: u64) -> IoResult { - let conn = try!(if config.use_ssl() { - Connection::connect_ssl_with_timeout(config.server(), config.port(), timeout_ms) - } else { - Connection::connect_with_timeout(config.server(), config.port(), timeout_ms) - }); - Ok(IrcServer { config: config, conn: conn, chanlists: Mutex::new(HashMap::new()), - alt_nick_index: RWLock::new(0u) }) - } - /// Reconnects to the IRC server. #[experimental] pub fn reconnect(&mut self) -> IoResult<()> {