From 1b26f1dd275e7ff947fcf2ecdbbad8f6bc1e0b49 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期五, 19 六月 2020 16:06:14 +0800
Subject: [PATCH] update

---
 service/test_client.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/service/test_client.c b/service/test_client.c
index 368f641..b204c11 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)
 {
@@ -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