Skip to content

Commit a2cb1f7

Browse files
authored
pass socket address into raw protosocket servers
Like the `protosocket_rpc::server`, this change passes the remote socket address to the connection server.
1 parent dc1b6bb commit a2cb1f7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

example-telnet/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl ServerConnector for ServerContext {
4747
optional_outbound: tokio::sync::mpsc::Sender<
4848
<<Self::Bindings as ConnectionBindings>::Serializer as Serializer>::Message,
4949
>,
50+
_address: std::net::SocketAddr,
5051
) -> <Self::Bindings as ConnectionBindings>::Reactor {
5152
StringReactor {
5253
outbound: optional_outbound,

protosocket-server/src/connection_server.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::future::Future;
22
use std::io::Error;
3+
use std::net::SocketAddr;
34
use std::pin::Pin;
45
use std::sync::Arc;
56
use std::task::Context;
@@ -21,6 +22,7 @@ pub trait ServerConnector: Unpin {
2122
optional_outbound: mpsc::Sender<
2223
<<Self::Bindings as ConnectionBindings>::Serializer as Serializer>::Message,
2324
>,
25+
address: SocketAddr,
2426
) -> <Self::Bindings as ConnectionBindings>::Reactor;
2527

2628
fn maximum_message_length(&self) -> usize {
@@ -108,7 +110,7 @@ impl<Connector: ServerConnector> Future for ProtosocketServer<Connector> {
108110
mpsc::channel(self.max_queued_outbound_messages);
109111
let reactor = self
110112
.connector
111-
.new_reactor(outbound_submission_queue.clone());
113+
.new_reactor(outbound_submission_queue.clone(), address);
112114
let stream = self.connector.connect(stream);
113115
let connection: Connection<Connector::Bindings> = Connection::new(
114116
stream,

0 commit comments

Comments
 (0)