CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
TestBase64Server.cpp
Go to the documentation of this file.
1// TestBase64Server.cpp : Simple XMLRPC server example. Usage: TestBase64Server serverPort
2//
3#if defined(_MSC_VER)
4# pragma warning(disable:4786) // identifier was truncated in debug info
5#endif
6
7
8#include <iostream>
9#include <fstream>
10#include <algorithm>
11#include <stdlib.h>
12
13
14#include "XmlRpc.h"
15using namespace XmlRpc;
16
17
18// The server
20
21// No arguments, result is Base64-encoded pngnow.png data.
23{
24public:
26
27 void execute(XmlRpcValue& params, XmlRpcValue& result)
28 {
29 std::ifstream infile("pngnow.png", std::ios::binary);
30 if (infile.fail())
31 infile.open("../pngnow.png", std::ios::binary);
32 if (infile.fail())
33 result = "Could not open file pngnow.png";
34 else {
35
37 int n = 0;
38 for (;; ++n) {
39 char c = infile.get();
40 if (infile.eof()) break;
41 data.push_back(c);
42 }
43 std::cerr << "Read " << n << " bytes from pngnow.png\n";
44 }
45 }
46} TestBase64(&s); // This constructor registers the method with the server
47
49
50int main(int argc, char* argv[])
51{
52 if (argc != 2) {
53 std::cerr << "Usage: TestBase64Server serverPort\n";
54 return -1;
55 }
56 int port = atoi(argv[1]);
57
58 //XmlRpc::setVerbosity(5);
59
60 // Create the server socket on the specified port
61 s.bindAndListen(port);
62
63 // Wait for requests indefinitely
64 s.work(-1.0);
65
66 return 0;
67}
68
const Int_t n
TTree * data
XmlRpcServer s
TestBase64(XmlRpcServer *s)
void execute(XmlRpcValue &params, XmlRpcValue &result)
Execute the method. Subclasses must provide a definition for this method.
TestBase64(XmlRpcServer *s)
Abstract class representing a single RPC method.
A class to handle XML RPC requests.
bool bindAndListen(int port, int backlog=5)
void work(double msTime)
Process client requests for the specified time.
RPC method arguments and results are represented by Values.
Definition XmlRpcValue.h:22
std::vector< char > BinaryData
Definition XmlRpcValue.h:39
int main()