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 # ifndef _WINDOWS
19 # include <poll.h>
20 # endif
21 #endif
22 
24 #include "xmlrpcpp/XmlRpcSource.h"
25 #include "xmlrpcpp/XmlRpcDecl.h"
26 
27 namespace XmlRpc {
28 
29 
30  // An abstract class supporting XML RPC methods
31  class XmlRpcServerMethod;
32 
33  // Class representing connections to specific clients
34  class XmlRpcServerConnection;
35 
36  // Class representing argument and result values
37  class XmlRpcValue;
38 
39 
42  public:
44  XmlRpcServer();
46  virtual ~XmlRpcServer();
47 
49  void enableIntrospection(bool enabled=true);
50 
52  void addMethod(XmlRpcServerMethod* method);
53 
55  void removeMethod(XmlRpcServerMethod* method);
56 
58  void removeMethod(const std::string& methodName);
59 
61  XmlRpcServerMethod* findMethod(const std::string& name) const;
62 
65  bool bindAndListen(int port, int backlog = 5);
66 
68  void work(double msTime);
69 
71  void exit();
72 
74  void shutdown();
75 
77  void listMethods(XmlRpcValue& result);
78 
79  // XmlRpcSource interface implementation
80 
82  virtual unsigned handleEvent(unsigned eventType);
83 
85  virtual void removeConnection(XmlRpcServerConnection*);
86 
87  inline int get_port() { return _port; }
88 
89  XmlRpcDispatch *get_dispatch() { return &_disp; }
90 
91  protected:
92 
94  virtual unsigned acceptConnection();
95 
97  virtual XmlRpcServerConnection* createConnection(int socket);
98 
100  int countFreeFDs();
101 
102  // Whether the introspection API is supported by this server
104 
105  // Event dispatcher
107 
108  // Collection of methods. This could be a set keyed on method name if we wanted...
109  typedef std::map< std::string, XmlRpcServerMethod* > MethodMap;
110  MethodMap _methods;
111 
112  // system methods
115 
116  int _port;
117 
118  // Flag indicating that accept had an error and needs to be retried.
120  // If we cannot accept(), retry after this many seconds. Hopefully there
121  // will be more free file descriptors later.
122  static const double ACCEPT_RETRY_INTERVAL_SEC;
123  // Retry time for accept.
125 
126  // Minimum number of free file descriptors before rejecting clients.
127  static const int FREE_FD_BUFFER;
128 #ifndef _WINDOWS
129  // List of all file descriptors, used for counting open files.
130  std::vector<struct pollfd> pollfds;
131 #endif
132  };
133 } // namespace XmlRpc
134 
135 #endif //_XMLRPCSERVER_H_
A class to handle XML RPC requests from a particular client.
static const double ACCEPT_RETRY_INTERVAL_SEC
Definition: XmlRpcServer.h:122
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
std::vector< struct pollfd > pollfds
Definition: XmlRpcServer.h:130
XmlRpcDispatch * get_dispatch()
Definition: XmlRpcServer.h:89
Abstract class representing a single RPC method.
XmlRpcServerMethod * _listMethods
Definition: XmlRpcServer.h:113
std::map< std::string, XmlRpcServerMethod *> MethodMap
Definition: XmlRpcServer.h:109
XmlRpcDispatch _disp
Definition: XmlRpcServer.h:106
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:41
static const int FREE_FD_BUFFER
Definition: XmlRpcServer.h:127
XmlRpcServerMethod * _methodHelp
Definition: XmlRpcServer.h:114


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix
autogenerated on Wed Oct 16 2019 03:27:40