Changeset 5393 in ntrip for trunk/GnssCenter/thrift
- Timestamp:
- Sep 9, 2013, 2:36:42 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GnssCenter/thrift/test_rtnet/rtnetThriftClient.cpp
r5392 r5393 1 1 2 2 #include <iomanip> 3 #include <sstream> 3 4 #include <vector> 5 #include <map> 4 6 #include <string> 7 #include <getopt.h> 5 8 6 9 #include <transport/TSocket.h> … … 37 40 }; 38 41 42 // Read Command-line Options 43 //////////////////////////////////////////////////////////////////////////////// 44 void parseCmdLine(int argc, char* argv[], map<string, string>& OPT) { 45 46 static struct option longOptions[] = { 47 {"host", required_argument, 0, 'h'}, 48 {"port", required_argument, 0, 'p'}, 49 }; 50 51 while (true) { 52 int index = 0; 53 int iarg = getopt_long(argc, argv, "h:p:", longOptions, &index); 54 if (iarg == -1) { 55 break; 56 } 57 if (optarg) { 58 OPT[longOptions[index].name] = string(optarg); 59 } 60 else { 61 OPT[longOptions[index].name] = "y"; 62 } 63 } 64 } 65 39 66 // Program 40 67 ////////////////////////////////////////////////////////////////////////////// 41 68 int main(int argc, char **argv) { 42 69 43 shared_ptr<TSocket> socket(new TSocket("localhost", 6666)); 70 // Parse Input Options 71 // ------------------- 72 map<string, string> OPT; 73 parseCmdLine(argc, argv, OPT); 74 if (OPT.find("port") == OPT.end()) { 75 cerr << "usage: rtnetThriftClient [--host <host>] --port <port>" << endl; 76 return 1; 77 } 78 string host = OPT.find("host") == OPT.end() ? "localhost" : OPT["host"]; 79 int port; istringstream(OPT["port"]) >> port; 80 81 shared_ptr<TSocket> socket(new TSocket(host, port)); 44 82 shared_ptr<TTransport> transport(new TBufferedTransport(socket)); 45 83 shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
Note:
See TracChangeset
for help on using the changeset viewer.