You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by al...@apache.org on 2019/12/14 14:52:44 UTC
[thrift] branch master updated: THRIFT-4995 Use `ToSocketAddrs` for
net addresses
This is an automated email from the ASF dual-hosted git repository.
allengeorge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new 98ce2c8 THRIFT-4995 Use `ToSocketAddrs` for net addresses
new 6e44378 Merge pull request #1919 from mpajkowski/to_socket_addrs
98ce2c8 is described below
commit 98ce2c8f2b3bb5aaee3e67a5b461dd1a87685cc0
Author: Marcin Pajkowski <ma...@gmail.com>
AuthorDate: Tue Nov 5 00:20:15 2019 +0100
THRIFT-4995 Use `ToSocketAddrs` for net addresses
---
lib/rs/src/server/threaded.rs | 7 +++----
lib/rs/src/transport/socket.rs | 6 +++---
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/rs/src/server/threaded.rs b/lib/rs/src/server/threaded.rs
index 8f8c082..cc658bd 100644
--- a/lib/rs/src/server/threaded.rs
+++ b/lib/rs/src/server/threaded.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-use std::net::{TcpListener, TcpStream};
+use std::net::{TcpListener, TcpStream, ToSocketAddrs};
use std::sync::Arc;
use threadpool::ThreadPool;
@@ -162,14 +162,13 @@ where
/// Listen for incoming connections on `listen_address`.
///
- /// `listen_address` should be in the form `host:port`,
- /// for example: `127.0.0.1:8080`.
+ /// `listen_address` should implement `ToSocketAddrs` trait.
///
/// Return `()` if successful.
///
/// Return `Err` when the server cannot bind to `listen_address` or there
/// is an unrecoverable error.
- pub fn listen(&mut self, listen_address: &str) -> ::Result<()> {
+ pub fn listen<A: ToSocketAddrs>(&mut self, listen_address: A) -> ::Result<()> {
let listener = TcpListener::bind(listen_address)?;
for stream in listener.incoming() {
match stream {
diff --git a/lib/rs/src/transport/socket.rs b/lib/rs/src/transport/socket.rs
index 0bef67b..a2e567e 100644
--- a/lib/rs/src/transport/socket.rs
+++ b/lib/rs/src/transport/socket.rs
@@ -18,7 +18,7 @@
use std::convert::From;
use std::io;
use std::io::{ErrorKind, Read, Write};
-use std::net::{Shutdown, TcpStream};
+use std::net::{Shutdown, TcpStream, ToSocketAddrs};
use super::{ReadHalf, TIoChannel, WriteHalf};
use {new_transport_error, TransportErrorKind};
@@ -81,8 +81,8 @@ impl TTcpChannel {
}
}
- /// Connect to `remote_address`, which should have the form `host:port`.
- pub fn open(&mut self, remote_address: &str) -> ::Result<()> {
+ /// Connect to `remote_address`, which should implement `ToSocketAddrs` trait.
+ pub fn open<A: ToSocketAddrs>(&mut self, remote_address: A) -> ::Result<()> {
if self.stream.is_some() {
Err(new_transport_error(
TransportErrorKind::AlreadyOpen,