在应用程序中,客户端通过SCTP多宿主连接到两个服务器。 github上的示例:
InetSocketAddress localAddress = SocketUtils.socketAddress(CLIENT_PRIMARY_HOST, CLIENT_PORT);
InetAddress localSecondaryAddress = SocketUtils.addressByName(CLIENT_SECONDARY_HOST);
InetSocketAddress remoteAddress = SocketUtils.socketAddress(SERVER_REMOTE_HOST, SERVER_REMOTE_PORT);
// Bind the client channel.
ChannelFuture bindFuture = b.bind(localAddress).sync();
// Get the underlying sctp channel
SctpChannel channel = (SctpChannel) bindFuture.channel();
// Bind the secondary address.
// Please note that, bindAddress in the client channel should be done before connecting if you have not
// enable Dynamic Address Configuration. See net.sctp.addip_enable kernel param
channel.bindAddress(localSecondaryAddress).sync();
// Finish connect
ChannelFuture connectFuture = channel.connect(remoteAddress).sync();
// Wait until the connection is closed.
connectFuture.channel().closeFuture().sync();
如何添加第二个remoteAddress
,以便客户端可以使用相同的端口连接到两台服务器?还是该客户端可以使用相同的端口连接两个服务器?