XmlRpcServer.h
Go to the documentation of this file.
1 // this file modified by Morgan Quigley on 22 Apr 2008.
2 // added features: server can be opened on port 0 and you can read back
3 // what port the OS gave you
4 
5 #ifndef _XMLRPCSERVER_H_
6 #define _XMLRPCSERVER_H_
7 //
8 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
9 //
10 #if defined(_MSC_VER)
11 # pragma warning(disable:4786) // identifier was truncated in debug info
12 #endif
13 
14 #ifndef MAKEDEPEND
15 # include <map>
16 # include <string>
17 # include <vector>
18 # include <poll.h>
19 #endif
20 
22 #include "xmlrpcpp/XmlRpcSource.h"
23 #include "xmlrpcpp/XmlRpcDecl.h"
24 
25 namespace XmlRpc {
26 
27 
28  // An abstract class supporting XML RPC methods
29  class XmlRpcServerMethod;
30 
31  // Class representing connections to specific clients
32  class XmlRpcServerConnection;
33 
34  // Class representing argument and result values
35  class XmlRpcValue;
36 
37 
40  public:
42  XmlRpcServer();
44  virtual ~XmlRpcServer();
45 
47  void enableIntrospection(bool enabled=true);
48 
50  void addMethod(XmlRpcServerMethod* method);
51 
53  void removeMethod(XmlRpcServerMethod* method);
54 
56  void removeMethod(const std::string& methodName);
57 
59  XmlRpcServerMethod* findMethod(const std::string& name) const;
60 
63  bool bindAndListen(int port, int backlog = 5);
64 
66  void work(double msTime);
67 
69  void exit();
70 
72  void shutdown();
73 
75  void listMethods(XmlRpcValue& result);
76 
77  // XmlRpcSource interface implementation
78 
80  virtual unsigned handleEvent(unsigned eventType);
81 
83  virtual void removeConnection(XmlRpcServerConnection*);
84 
85  inline int get_port() { return _port; }
86 
87  XmlRpcDispatch *get_dispatch() { return &_disp; }
88 
89  protected:
90 
92  virtual unsigned acceptConnection();
93 
95  virtual XmlRpcServerConnection* createConnection(int socket);
96 
98  int countFreeFDs();
99 
100  // Whether the introspection API is supported by this server
102 
103  // Event dispatcher
105 
106  // Collection of methods. This could be a set keyed on method name if we wanted...
107  typedef std::map< std::string, XmlRpcServerMethod* > MethodMap;
108  MethodMap _methods;
109 
110  // system methods
113 
114  int _port;
115 
116  // Flag indicating that accept had an error and needs to be retried.
118  // If we cannot accept(), retry after this many seconds. Hopefully there
119  // will be more free file descriptors later.
120  static const double ACCEPT_RETRY_INTERVAL_SEC;
121  // Retry time for accept.
123 
124  // Minimum number of free file descriptors before rejecting clients.
125  static const int FREE_FD_BUFFER;
126  // List of all file descriptors, used for counting open files.
127  std::vector<struct pollfd> pollfds;
128  };
129 } // namespace XmlRpc
130 
131 #endif //_XMLRPCSERVER_H_
A class to handle XML RPC requests from a particular client.
static const double ACCEPT_RETRY_INTERVAL_SEC
Definition: XmlRpcServer.h:120
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
std::vector< struct pollfd > pollfds
Definition: XmlRpcServer.h:127
XmlRpcDispatch * get_dispatch()
Definition: XmlRpcServer.h:87
Abstract class representing a single RPC method.
XmlRpcServerMethod * _listMethods
Definition: XmlRpcServer.h:111
std::map< std::string, XmlRpcServerMethod * > MethodMap
Definition: XmlRpcServer.h:107
XmlRpcDispatch _disp
Definition: XmlRpcServer.h:104
An RPC source represents a file descriptor to monitor.
Definition: XmlRpcSource.h:16
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:52
A class to handle XML RPC requests.
Definition: XmlRpcServer.h:39
static const int FREE_FD_BUFFER
Definition: XmlRpcServer.h:125
XmlRpcServerMethod * _methodHelp
Definition: XmlRpcServer.h:112


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix
autogenerated on Sun Feb 3 2019 03:29:51