From 591aacee97f4a6486631c38a6b418e20b2c4109c Mon Sep 17 00:00:00 2001 From: wangzhengquan <wangzhengquan85@126.com> Date: 星期四, 10 九月 2020 14:56:47 +0800 Subject: [PATCH] update --- service/test_client.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/service/test_client.c b/service/test_client.c index 368f641..953be38 100644 --- a/service/test_client.c +++ b/service/test_client.c @@ -1,12 +1,14 @@ #include "usg_common.h" #include "netdisk.h" #include "hcnetdisk.h" +#include "properties_config.h" #include <jsoncpp/json/json.h> #include <nng/nng.h> #include <nng/protocol/reqrep0/rep.h> #include <nng/protocol/reqrep0/req.h> -const char *url = "tcp://127.0.0.1:8899"; -const char *localUrl = "tcp://127.0.0.1:9988"; + +PropertiesConfig config("../data/config.txt"); + void fatal(const char *func, int rv) { @@ -110,13 +112,13 @@ end["year"] = 2020; end["mon"] = 4; end["day"] = 10; - end["hour"] = 15; - end["min"] = 20; + end["hour"] = 14; + end["min"] = 40; end["sec"] = 0; arguments["end"] = end; arguments["channel"] = 1; - arguments["destpath"] = "/home/basic/data/Downloads/test"; + arguments["destpath"] = "/home/basic/data/Downloads"; arguments["host"] = "192.168.20.11"; arguments["port"] = 8000; @@ -152,7 +154,7 @@ if ((rv = nng_req0_open(&sock)) != 0) { fatal("nng_socket", rv); } - if ((rv = nng_dial(sock, url, NULL, 0)) != 0) { + if ((rv = nng_dial(sock, config.get("server_url").c_str(), NULL, 0)) != 0) { fatal("nng_dial", rv); } //printf("CLIENT: SENDING DATE REQUEST\n"); @@ -187,7 +189,7 @@ } int -server() +server(const char *url) { nng_socket sock; int rv; @@ -195,7 +197,7 @@ if ((rv = nng_rep0_open(&sock)) != 0) { fatal("nng_rep0_open", rv); } - if ((rv = nng_listen(sock, localUrl, NULL, 0)) != 0) { + if ((rv = nng_listen(sock, url, NULL, 0)) != 0) { fatal("nng_listen", rv); } for (;;) { @@ -230,7 +232,7 @@ pthread_t tid; pthread_create(&tid, NULL, client, NULL); - server(); + server(config.get("client_url").c_str()); return 0; } \ No newline at end of file -- Gitblit v1.8.0