| | |
| | | #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) |
| | | { |
| | |
| | | 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; |
| | | |
| | |
| | | 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"); |
| | |
| | | } |
| | | |
| | | int |
| | | server() |
| | | server(const char *url) |
| | | { |
| | | nng_socket sock; |
| | | int rv; |
| | |
| | | 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 (;;) { |
| | |
| | | pthread_t tid; |
| | | pthread_create(&tid, NULL, client, NULL); |
| | | |
| | | server(); |
| | | server(config.get("client_url").c_str()); |
| | | return 0; |
| | | |
| | | } |