From 210b00f09d1c04e9d670be404adb18a625fb042f Mon Sep 17 00:00:00 2001 From: Pierre Avital Date: Wed, 13 Sep 2023 15:27:11 +0200 Subject: [PATCH 1/4] add -l option to examples --- examples/unix/c11/z_get.c | 8 ++++++-- examples/unix/c11/z_info.c | 8 ++++++-- examples/unix/c11/z_pub.c | 11 +++-------- examples/unix/c11/z_pub_st.c | 8 ++++++-- examples/unix/c11/z_put.c | 8 ++++++-- examples/unix/c11/z_queryable.c | 8 ++++++-- examples/unix/c11/z_sub.c | 8 ++++++-- examples/unix/c11/z_sub_st.c | 8 ++++++-- examples/unix/c99/z_get.c | 8 ++++++-- examples/unix/c99/z_info.c | 8 ++++++-- examples/unix/c99/z_pub.c | 8 ++++++-- examples/unix/c99/z_pub_st.c | 8 ++++++-- examples/unix/c99/z_put.c | 8 ++++++-- examples/unix/c99/z_queryable.c | 8 ++++++-- examples/unix/c99/z_sub.c | 8 ++++++-- examples/unix/c99/z_sub_st.c | 8 ++++++-- 16 files changed, 93 insertions(+), 38 deletions(-) diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index c1971702e..400cd39b4 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) { const char *value = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:v:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -53,11 +53,15 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case 'v': value = optarg; break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 68091cde8..5697d5c4f 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -32,7 +32,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "e:m:")) != -1) { + while ((opt = getopt(argc, argv, "e:m:l:")) != -1) { switch (opt) { case 'e': locator = optarg; @@ -40,8 +40,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'e' || optopt == 'm') { + if (optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index e7b7e64bc..cc4252b24 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -46,19 +46,14 @@ int main(int argc, char **argv) { mode = optarg; break; case 'l': - opt = atoi(optarg); - value = z_malloc(opt + 1); - memset(value, 'A', opt); - value[opt] = 0; - for (int i = opt - 1; opt > 0; i--, opt /= 10) { - value[i] = '0' + (opt % 10); - } + locator = optarg; + mode = "peer"; break; case 'n': n = atoi(optarg); break; case '?': - if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c11/z_pub_st.c b/examples/unix/c11/z_pub_st.c index 1e27ade12..c8440b2e9 100644 --- a/examples/unix/c11/z_pub_st.c +++ b/examples/unix/c11/z_pub_st.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:v:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -40,8 +40,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index 2a403af44..c4aca1cc9 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:v:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -40,8 +40,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index e6f9d8e48..392778381 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -41,7 +41,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:v:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -52,11 +52,15 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case 'v': value = optarg; break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index 7cc329416..d004ead95 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -44,8 +44,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index 7a8b96143..103c68a06 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -44,8 +44,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index f20104028..b7097b445 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) { const char *value = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:v:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -53,11 +53,15 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case 'v': value = optarg; break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index a06f13ee3..0497ea6f8 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -32,7 +32,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "e:m:")) != -1) { + while ((opt = getopt(argc, argv, "e:m:l:")) != -1) { switch (opt) { case 'e': locator = optarg; @@ -40,8 +40,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'e' || optopt == 'm') { + if (optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index a5839f36f..bd83501f5 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:v:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -40,8 +40,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_pub_st.c b/examples/unix/c99/z_pub_st.c index 1261fcd50..36ec2457f 100644 --- a/examples/unix/c99/z_pub_st.c +++ b/examples/unix/c99/z_pub_st.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:v:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -40,8 +40,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 45ebe29b4..461fa7a32 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:v:e:")) != -1) { + while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -40,8 +40,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index e920b1035..9a76be6d7 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -37,7 +37,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:v:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -51,8 +51,12 @@ int main(int argc, char **argv) { case 'e': locator = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index db294ee00..a04d9e03c 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -44,8 +44,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); diff --git a/examples/unix/c99/z_sub_st.c b/examples/unix/c99/z_sub_st.c index 4a87cce3b..e3f7f6dec 100644 --- a/examples/unix/c99/z_sub_st.c +++ b/examples/unix/c99/z_sub_st.c @@ -33,7 +33,7 @@ int main(int argc, char **argv) { char *locator = NULL; int opt; - while ((opt = getopt(argc, argv, "k:e:m:")) != -1) { + while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { switch (opt) { case 'k': keyexpr = optarg; @@ -44,8 +44,12 @@ int main(int argc, char **argv) { case 'm': mode = optarg; break; + case 'l': + locator = optarg; + mode = "peer"; + break; case '?': - if (optopt == 'k' || optopt == 'e' || optopt == 'm') { + if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { fprintf(stderr, "Option -%c requires an argument.\n", optopt); } else { fprintf(stderr, "Unknown option `-%c'.\n", optopt); From da7eab72c178cc7396fbcf0c480e60e9b208a051 Mon Sep 17 00:00:00 2001 From: Pierre Avital Date: Fri, 15 Sep 2023 15:05:17 +0200 Subject: [PATCH 2/4] use proper listen config for -l --- examples/unix/c11/z_get.c | 15 +++++++++------ examples/unix/c11/z_info.c | 15 +++++++++------ examples/unix/c11/z_pub.c | 15 +++++++++------ examples/unix/c11/z_pub_st.c | 15 +++++++++------ examples/unix/c11/z_put.c | 15 +++++++++------ examples/unix/c11/z_queryable.c | 15 +++++++++------ examples/unix/c11/z_sub.c | 15 +++++++++------ examples/unix/c11/z_sub_st.c | 15 +++++++++------ examples/unix/c99/z_get.c | 15 +++++++++------ examples/unix/c99/z_info.c | 15 +++++++++------ examples/unix/c99/z_pub.c | 15 +++++++++------ examples/unix/c99/z_pub_st.c | 15 +++++++++------ examples/unix/c99/z_put.c | 15 +++++++++------ examples/unix/c99/z_queryable.c | 15 +++++++++------ examples/unix/c99/z_sub.c | 15 +++++++++------ examples/unix/c99/z_sub_st.c | 15 +++++++++------ src/net/session.c | 18 ++++++++++++++++-- zenohpico.pc | 2 +- 18 files changed, 161 insertions(+), 99 deletions(-) diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index 400cd39b4..000993ab9 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -38,7 +38,8 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - const char *locator = NULL; + const char *clocator = NULL; + const char *llocator = NULL; const char *value = NULL; int opt; @@ -48,14 +49,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'v': value = optarg; @@ -74,8 +74,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 5697d5c4f..2740d5110 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -29,20 +29,20 @@ void print_zid(const z_id_t *id, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "e:m:l:")) != -1) { switch (opt) { case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_pub.c b/examples/unix/c11/z_pub.c index cc4252b24..e4f96b7ea 100644 --- a/examples/unix/c11/z_pub.c +++ b/examples/unix/c11/z_pub.c @@ -27,7 +27,8 @@ int main(int argc, char **argv) { char *const default_value = "Pub from Pico!"; char *value = default_value; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int n = 10; int opt; @@ -40,14 +41,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'n': n = atoi(optarg); @@ -66,8 +66,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_pub_st.c b/examples/unix/c11/z_pub_st.c index c8440b2e9..f2b0fef79 100644 --- a/examples/unix/c11/z_pub_st.c +++ b/examples/unix/c11/z_pub_st.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index c4aca1cc9..0445d48f9 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-put"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 392778381..31a7d10ba 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -38,7 +38,8 @@ void query_handler(const z_query_t *query, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { @@ -47,14 +48,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'v': value = optarg; @@ -73,8 +73,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index d004ead95..7b097fe72 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index 103c68a06..567290484 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index b7097b445..65e22f91b 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -38,7 +38,8 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - const char *locator = NULL; + const char *clocator = NULL; + const char *llocator = NULL; const char *value = NULL; int opt; @@ -48,14 +49,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case 'v': value = optarg; @@ -74,8 +74,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index 0497ea6f8..901587bd8 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -29,20 +29,20 @@ void print_zid(const z_id_t *id, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "e:m:l:")) != -1) { switch (opt) { case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index bd83501f5..8ee66dfdb 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_pub_st.c b/examples/unix/c99/z_pub_st.c index 36ec2457f..96eeba2a4 100644 --- a/examples/unix/c99/z_pub_st.c +++ b/examples/unix/c99/z_pub_st.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-pub"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 461fa7a32..be22b6eea 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -23,7 +23,8 @@ int main(int argc, char **argv) { const char *keyexpr = "demo/example/zenoh-pico-put"; const char *value = "Pub from Pico!"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:v:e:m:l:")) != -1) { @@ -35,14 +36,13 @@ int main(int argc, char **argv) { value = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'v' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -58,8 +58,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index 9a76be6d7..8ddcf74e6 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -34,7 +34,8 @@ void query_handler(const z_query_t *query, void *ctx) { int main(int argc, char **argv) { const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + const char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:v:l:")) != -1) { @@ -49,11 +50,10 @@ int main(int argc, char **argv) { mode = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'v' || optopt == 'l') { @@ -69,8 +69,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index a04d9e03c..0f616525f 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *arg) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/examples/unix/c99/z_sub_st.c b/examples/unix/c99/z_sub_st.c index e3f7f6dec..fac31bd46 100644 --- a/examples/unix/c99/z_sub_st.c +++ b/examples/unix/c99/z_sub_st.c @@ -30,7 +30,8 @@ void data_handler(const z_sample_t *sample, void *arg) { int main(int argc, char **argv) { const char *keyexpr = "demo/example/**"; const char *mode = "client"; - char *locator = NULL; + char *clocator = NULL; + char *llocator = NULL; int opt; while ((opt = getopt(argc, argv, "k:e:m:l:")) != -1) { @@ -39,14 +40,13 @@ int main(int argc, char **argv) { keyexpr = optarg; break; case 'e': - locator = optarg; + clocator = optarg; break; case 'm': mode = optarg; break; case 'l': - locator = optarg; - mode = "peer"; + llocator = optarg; break; case '?': if (optopt == 'k' || optopt == 'e' || optopt == 'm' || optopt == 'l') { @@ -62,8 +62,11 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - if (locator != NULL) { - zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(locator)); + if (clocator != NULL) { + zp_config_insert(z_config_loan(&config), Z_CONFIG_CONNECT_KEY, z_string_make(clocator)); + } + if (llocator != NULL) { + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(llocator)); } printf("Opening session...\n"); diff --git a/src/net/session.c b/src/net/session.c index 28ceb6725..e00988f10 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -16,7 +16,10 @@ #include #include +#include "zenoh-pico/api/primitives.h" #include "zenoh-pico/collections/bytes.h" +#include "zenoh-pico/collections/string.h" +#include "zenoh-pico/config.h" #include "zenoh-pico/net/memory.h" #include "zenoh-pico/protocol/core.h" #include "zenoh-pico/session/utils.h" @@ -61,7 +64,9 @@ int8_t _z_open(_z_session_t *zn, _z_config_t *config) { if (config != NULL) { _z_str_array_t locators = _z_str_array_empty(); - if (_z_config_get(config, Z_CONFIG_CONNECT_KEY) == NULL) { // Scout if peer is not configured + char *connect = _z_config_get(config, Z_CONFIG_CONNECT_KEY); + char *listen = _z_config_get(config, Z_CONFIG_CONNECT_KEY); + if (connect == NULL && listen == NULL) { // Scout if peer is not configured opt_as_str = _z_config_get(config, Z_CONFIG_SCOUTING_WHAT_KEY); if (opt_as_str == NULL) { opt_as_str = Z_CONFIG_SCOUTING_WHAT_DEFAULT; @@ -88,8 +93,17 @@ int8_t _z_open(_z_session_t *zn, _z_config_t *config) { } _z_hello_list_free(&hellos); } else { + int key = Z_CONFIG_CONNECT_KEY; + if (listen != NULL) { + if (connect == NULL) { + key = Z_CONFIG_LISTEN_KEY; + _zp_config_insert(config, Z_CONFIG_MODE_KEY, _z_string_make(Z_CONFIG_MODE_PEER)); + } else { + return _Z_ERR_GENERIC; + } + } locators = _z_str_array_make(1); - locators.val[0] = _z_str_clone(_z_config_get(config, Z_CONFIG_CONNECT_KEY)); + locators.val[0] = _z_str_clone(_z_config_get(config, key)); } ret = _Z_ERR_SCOUT_NO_RESULTS; diff --git a/zenohpico.pc b/zenohpico.pc index 743095b12..3254c5f2a 100644 --- a/zenohpico.pc +++ b/zenohpico.pc @@ -3,6 +3,6 @@ prefix=/usr/local Name: zenohpico Description: URL: -Version: 0.10.20230913dev +Version: 0.10.20230915dev Cflags: -I${prefix}/ Libs: -L${prefix}/ -lzenohpico From 0194d928086d79e8a6fb755d3e995de5e8579902 Mon Sep 17 00:00:00 2001 From: Pierre Avital Date: Fri, 15 Sep 2023 15:16:04 +0200 Subject: [PATCH 3/4] fix multicast test --- tests/z_peer_multicast_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/z_peer_multicast_test.c b/tests/z_peer_multicast_test.c index 125c90039..29b05223a 100644 --- a/tests/z_peer_multicast_test.c +++ b/tests/z_peer_multicast_test.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) { z_owned_config_t config = z_config_default(); zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make("peer")); - zp_config_insert(z_loan(config), Z_CONFIG_CONNECT_KEY, z_string_make(argv[1])); + zp_config_insert(z_loan(config), Z_CONFIG_LISTEN_KEY, z_string_make(argv[1])); for (unsigned int i = 0; i < SET; i++) idx[i] = i; From f63c88e82d47e13e55e27b4279d95db7d86c7a9c Mon Sep 17 00:00:00 2001 From: Pierre Avital Date: Fri, 15 Sep 2023 15:59:33 +0200 Subject: [PATCH 4/4] fix typo that broke everything --- src/net/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/session.c b/src/net/session.c index e00988f10..2f2b0c93e 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -65,7 +65,7 @@ int8_t _z_open(_z_session_t *zn, _z_config_t *config) { if (config != NULL) { _z_str_array_t locators = _z_str_array_empty(); char *connect = _z_config_get(config, Z_CONFIG_CONNECT_KEY); - char *listen = _z_config_get(config, Z_CONFIG_CONNECT_KEY); + char *listen = _z_config_get(config, Z_CONFIG_LISTEN_KEY); if (connect == NULL && listen == NULL) { // Scout if peer is not configured opt_as_str = _z_config_get(config, Z_CONFIG_SCOUTING_WHAT_KEY); if (opt_as_str == NULL) {