BOSS 8.0.0
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#include <algorithm>
8#include <fstream>
9#include <iostream>
10#include <stdlib.h>
11
12#include "XmlRpc.h"
13using namespace XmlRpc;
14
15// The server
17
18// No arguments, result is Base64-encoded pngnow.png data.
20public:
21 TestBase64( XmlRpcServer* s ) : XmlRpcServerMethod( "TestBase64", s ) {}
22
23 void execute( XmlRpcValue& params, XmlRpcValue& result ) {
24 std::ifstream infile( "pngnow.png", std::ios::binary );
25 if ( infile.fail() ) infile.open( "../pngnow.png", std::ios::binary );
26 if ( infile.fail() ) result = "Could not open file pngnow.png";
27 else
28 {
29
31 int n = 0;
32 for ( ;; ++n )
33 {
34 char c = infile.get();
35 if ( infile.eof() ) break;
36 data.push_back( c );
37 }
38 std::cerr << "Read " << n << " bytes from pngnow.png\n";
39 }
40 }
41} TestBase64( &s ); // This constructor registers the method with the server
42
43int main( int argc, char* argv[] ) {
44 if ( argc != 2 )
45 {
46 std::cerr << "Usage: TestBase64Server serverPort\n";
47 return -1;
48 }
49 int port = atoi( argv[1] );
50
51 // XmlRpc::setVerbosity(5);
52
53 // Create the server socket on the specified port
54 s.bindAndListen( port );
55
56 // Wait for requests indefinitely
57 s.work( -1.0 );
58
59 return 0;
60}
const Int_t n
TTree * data
XmlRpcServer s
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)
XmlRpcServerMethod(std::string const &name, XmlRpcServer *server=0)
Constructor.
A class to handle XML RPC requests.
RPC method arguments and results are represented by Values.
Definition XmlRpcValue.h:22
std::vector< char > BinaryData
Definition XmlRpcValue.h:37
int main()
Definition phokhara.cc:42