Fix _LLMP_BIND_ADDR for Windows (#285)
* ipv6 * client connects to localhost * v4 when v6 not available * remove v6 addr
This commit is contained in:
parent
774cfb685e
commit
d136ee7427
@ -138,10 +138,14 @@ const _LLMP_B2B_BLOCK_TIME: Duration = Duration::from_millis(3_000);
|
|||||||
/// If broker2broker is enabled, bind to public IP
|
/// If broker2broker is enabled, bind to public IP
|
||||||
#[cfg(feature = "llmp_bind_public")]
|
#[cfg(feature = "llmp_bind_public")]
|
||||||
const _LLMP_BIND_ADDR: &str = "0.0.0.0";
|
const _LLMP_BIND_ADDR: &str = "0.0.0.0";
|
||||||
|
|
||||||
/// If broker2broker is disabled, bind to localhost
|
/// If broker2broker is disabled, bind to localhost
|
||||||
#[cfg(not(feature = "llmp_bind_public"))]
|
#[cfg(not(feature = "llmp_bind_public"))]
|
||||||
const _LLMP_BIND_ADDR: &str = "127.0.0.1";
|
const _LLMP_BIND_ADDR: &str = "127.0.0.1";
|
||||||
|
|
||||||
|
/// LLMP Client connects to this address
|
||||||
|
const _LLMP_CONNECT_ADDR: &str = "localhost";
|
||||||
|
|
||||||
/// An env var of this value indicates that the set value was a NULL PTR
|
/// An env var of this value indicates that the set value was a NULL PTR
|
||||||
const _NULL_ENV_STR: &str = "_NULL";
|
const _NULL_ENV_STR: &str = "_NULL";
|
||||||
|
|
||||||
@ -2577,14 +2581,14 @@ where
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
/// Create a [`LlmpClient`], getting the ID from a given port
|
/// Create a [`LlmpClient`], getting the ID from a given port
|
||||||
pub fn create_attach_to_tcp(mut shmem_provider: SP, port: u16) -> Result<Self, Error> {
|
pub fn create_attach_to_tcp(mut shmem_provider: SP, port: u16) -> Result<Self, Error> {
|
||||||
let mut stream = match TcpStream::connect(format!("{}:{}", _LLMP_BIND_ADDR, port)) {
|
let mut stream = match TcpStream::connect((_LLMP_CONNECT_ADDR, port)) {
|
||||||
Ok(stream) => stream,
|
Ok(stream) => stream,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
match e.kind() {
|
match e.kind() {
|
||||||
std::io::ErrorKind::ConnectionRefused => {
|
std::io::ErrorKind::ConnectionRefused => {
|
||||||
//connection refused. loop till the broker is up
|
//connection refused. loop till the broker is up
|
||||||
loop {
|
loop {
|
||||||
match TcpStream::connect(format!("{}:{}", _LLMP_BIND_ADDR, port)) {
|
match TcpStream::connect((_LLMP_CONNECT_ADDR, port)) {
|
||||||
Ok(stream) => break stream,
|
Ok(stream) => break stream,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
dbg!("Connection Refused.. Retrying");
|
dbg!("Connection Refused.. Retrying");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user